Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
uyarn marked this conversation as resolved.
Show resolved Hide resolved
}
return (
<ul class={this.classes}>
Expand Down
Loading