Skip to content

Commit 6886a83

Browse files
authored
Fix: selecting typed value on blur in single-select (#8049)
2 parents 6a6e3c8 + 57e7c9a commit 6886a83

File tree

1 file changed

+7
-2
lines changed
  • packages/components/src/components/single-select

1 file changed

+7
-2
lines changed

packages/components/src/components/single-select/shadow.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,15 @@ export class KolSingleSelect implements SingleSelectAPI {
8787
* Closes the dropdown and resets the opened state.
8888
*/
8989
private onBlur() {
90-
if (Array.isArray(this.state._options) && this.state._options.length > 0 && !this.state._options.some((option) => option.label === this._inputValue)) {
91-
this._inputValue = this.state._options.find((option) => (option as Option<string>).value === this._value)?.label as string;
90+
const matchingOption = this.state._options?.find((option) => (option.label as string)?.toLowerCase() === this._inputValue?.toLowerCase());
91+
92+
if (matchingOption) {
93+
this.selectOption(matchingOption as Option<string>);
94+
} else {
95+
this._inputValue = this.state._options?.find((option) => (option as Option<string>).value === this._value)?.label as string;
9296
this._filteredOptions = [...this.state._options];
9397
}
98+
9499
this._isOpen = false;
95100
this._hasOpened = false;
96101
}

0 commit comments

Comments
 (0)