Skip to content

Commit 3e2d8ed

Browse files
committed
fix: close button functionality
1 parent 6410dec commit 3e2d8ed

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class PfSearchInput extends LitElement {
8989

9090
/** True when the user just clicked the close button */
9191
#clickedCloseButton = false;
92+
#setExpanded = false;
9293

9394
#combobox = ComboboxController.of(this, {
9495
getItems: () => this.options,
@@ -299,7 +300,16 @@ export class PfSearchInput extends LitElement {
299300

300301
async #showListbox() {
301302
await new Promise(requestAnimationFrame);
302-
if (!this.disabled) {
303+
if (this.disabled) {
304+
return;
305+
};
306+
307+
if (this.#setExpanded) {
308+
// If expanded is set to true on clicking close button
309+
// set expanded to false
310+
this.#setExpanded = false;
311+
this.expanded = false;
312+
} else {
303313
this.expanded ||= true;
304314
}
305315
}
@@ -322,10 +332,7 @@ export class PfSearchInput extends LitElement {
322332
#setIsExpanded() {
323333
if (this.#clickedCloseButton) {
324334
this.#clickedCloseButton = false;
325-
setTimeout(() =>{
326-
this.hide();
327-
// prevent the listbox from showing when we only intend to clear the input
328-
}, 10);
335+
this.#setExpanded = true;
329336
return true;
330337
}
331338
return this.expanded;

0 commit comments

Comments
 (0)