Skip to content

Commit

Permalink
fix(auto-complete): options is an empty array, empty is not effective (
Browse files Browse the repository at this point in the history
…#3474)

* fix(auto-complete): options is an empty array, empty is not effective

* chore: revert code

* chore: fix cr
  • Loading branch information
liweijie0812 authored Feb 6, 2025
1 parent bafd315 commit 011fd41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/auto-complete/auto-complete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default defineComponent({
/>
);
// 联想词列表
const listContent = (
const listContent = Array.isArray(this.options) && (
<AutoCompleteOptionList
ref="optionListRef"
value={this.tValue}
Expand All @@ -170,16 +170,15 @@ export default defineComponent({
highlightKeyword={this.highlightKeyword}
filterable={this.filterable}
filter={this.filter}
empty={this.empty}
empty={renderTNodeJSX(this, 'empty')}
scopedSlots={{
option: this.$scopedSlots.option,
empty: this.$scopedSlots.empty,
}}
/>
);
const topContent = renderTNodeJSX(this, 'panelTopContent');
const bottomContent = renderTNodeJSX(this, 'panelBottomContent');
const panelContent = topContent || this.options?.length || bottomContent ? (
const panelContent = topContent || listContent || bottomContent ? (
<div class={`${this.classPrefix}-auto-complete__panel`}>
{topContent}
{listContent}
Expand Down
6 changes: 3 additions & 3 deletions src/auto-complete/option-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { AutoCompleteOptionObj, TdAutoCompleteProps } from './type';
import log from '../_common/js/log';
import { useConfig, usePrefixClass } from '../hooks/useConfig';
import { on, off } from '../utils/dom';
import { renderTNodeJSX } from '../utils/render-tnode';

export default defineComponent({
name: 'AutoCompleteOptionList',
Expand Down Expand Up @@ -147,8 +146,9 @@ export default defineComponent({

render() {
if (!this.tOptions.length) {
const empty = renderTNodeJSX(this, 'empty');
return <div class={`${this.classPrefix}-auto-complete__panel--empty`}>{empty || this.globalConfig.empty}</div>;
return (
<div class={`${this.classPrefix}-auto-complete__panel--empty`}>{this.empty || this.globalConfig.empty}</div>
);
}
return (
<ul class={this.classes}>
Expand Down

0 comments on commit 011fd41

Please sign in to comment.