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 delayed display of single-select value #6885

Merged
merged 1 commit into from
Sep 26, 2024
Merged
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
15 changes: 10 additions & 5 deletions packages/components/src/components/single-select/shadow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -640,25 +641,29 @@ export class KolSingleSelect implements SingleSelectAPI {
public validateValue(value?: string): void {
this.controller.validateValue(value);
this.oldValue = value;
this.updateInputValue(value);
}

@Listen('mousemove')
public handleMouseEvent() {
this.blockSuggestionMouseOver = false;
}

private updateInputValue(value?: string) {
if (Array.isArray(this._options)) {
const matchedOption = this._options.find((option) => (option as Option<string>).value === value);
this._inputValue = matchedOption ? (matchedOption.label as string) : '';
}
}

public componentWillLoad(): void {
this.refOptions = [];
this._alert = this._alert === true;
this._touched = this._touched === true;
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<string>).value === this._value);
this._inputValue = matchedOption ? (matchedOption.label as string) : '';
}
this.updateInputValue(this._value);
}

private onChange(event: Event): void {
Expand Down
Loading