Skip to content

Commit c8fc771

Browse files
committed
fix: reset combobox selected state
1 parent 6c23f3e commit c8fc771

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

elements/pf-search-input/pf-search-input.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ export class PfSearchInput extends LitElement {
248248
#onClickCloseButton() {
249249
this._toggleInput!.value = '';
250250
this.#updateValue(this._toggleInput?.value ?? '');
251-
this.#combobox.selected = [];
252251
this.#clickedCloseButton = true;
253252
this._toggleInput?.focus();
254253
}
@@ -262,9 +261,6 @@ export class PfSearchInput extends LitElement {
262261

263262
#onChange() {
264263
this.#updateValue(this._toggleInput?.value ?? '');
265-
if (this.value !== this.#combobox.selected[0]?.value) {
266-
this.#combobox.selected = [];
267-
}
268264
}
269265

270266
#onSubmit(event: KeyboardEvent) {
@@ -275,6 +271,11 @@ export class PfSearchInput extends LitElement {
275271

276272
#updateValue(value: string) {
277273
this.value = value;
274+
// it's necessary to reset the 'selected' state of combobox
275+
// since otherwise, combobox controller will attempt to prevent us from
276+
// re-selecting the last-selected item, even though pf-search-input
277+
// doesn't have a selected property
278+
this.#combobox.selected = [];
278279
}
279280

280281
#onKeyDown(event: KeyboardEvent) {

0 commit comments

Comments
 (0)