diff --git a/packages/components/src/components/single-select/shadow.tsx b/packages/components/src/components/single-select/shadow.tsx index cd33bab727..ca5d30d9cc 100644 --- a/packages/components/src/components/single-select/shadow.tsx +++ b/packages/components/src/components/single-select/shadow.tsx @@ -614,6 +614,7 @@ export class KolSingleSelect implements SingleSelectAPI { public validateOptions(value?: OptionsPropType): void { this.controller.validateOptions(value); this._filteredOptions = value; + this.updateInputValue(this._value); } @Watch('_required') @@ -640,6 +641,7 @@ export class KolSingleSelect implements SingleSelectAPI { public validateValue(value?: string): void { this.controller.validateValue(value); this.oldValue = value; + this.updateInputValue(value); } @Listen('mousemove') @@ -647,6 +649,13 @@ export class KolSingleSelect implements SingleSelectAPI { this.blockSuggestionMouseOver = false; } + private updateInputValue(value?: string) { + if (Array.isArray(this._options)) { + const matchedOption = this._options.find((option) => (option as Option).value === value); + this._inputValue = matchedOption ? (matchedOption.label as string) : ''; + } + } + public componentWillLoad(): void { this.refOptions = []; this._alert = this._alert === true; @@ -654,11 +663,7 @@ export class KolSingleSelect implements SingleSelectAPI { this.controller.componentWillLoad(); this.oldValue = this._value; this._filteredOptions = this._options; - - if (Array.isArray(this._options)) { - const matchedOption = this._options.find((option) => (option as Option).value === this._value); - this._inputValue = matchedOption ? (matchedOption.label as string) : ''; - } + this.updateInputValue(this._value); } private onChange(event: Event): void {