@@ -98,7 +98,7 @@ export class PfSearchInput extends LitElement {
9898 getToggleButton : ( ) => this . _toggleButton ?? null ,
9999 getComboboxInput : ( ) => this . _toggleInput ?? null ,
100100 isExpanded : ( ) => this . expanded ,
101- requestShowListbox : ( ) => void ( this . expanded ||= true ) ,
101+ requestShowListbox : ( ) => this . #showListbox ( ) ,
102102 requestHideListbox : ( ) => void ( this . expanded &&= false ) ,
103103 setItemHidden : ( item , hidden ) => ( item . id !== 'placeholder' ) && void ( item . hidden = hidden ) ,
104104 isItem : item => item instanceof PfOption ,
@@ -181,7 +181,7 @@ export class PfSearchInput extends LitElement {
181181 < input
182182 id ="toggle-input "
183183 ?disabled ="${ disabled } "
184- @change =${ this . #onChange}
184+ @input =${ this . #onChange}
185185 @keyup =${ this . #onSubmit}
186186 placeholder="${ placeholder } "
187187 >
@@ -244,6 +244,13 @@ export class PfSearchInput extends LitElement {
244244 this . dispatchEvent ( new PfSearchChangeEvent ( ) ) ;
245245 }
246246
247+ @observes ( 'value' )
248+ private collapseOnEmpty ( ) {
249+ if ( this . value === '' ) {
250+ this . expanded = false ;
251+ }
252+ }
253+
247254 async #doExpand( ) {
248255 try {
249256 await this . #float. show ( { placement : this . position || 'bottom' , flip : ! ! this . enableFlip } ) ;
@@ -316,6 +323,17 @@ export class PfSearchInput extends LitElement {
316323 this . dispatchEvent ( new PfSearchChangeEvent ( ) ) ;
317324 }
318325 }
326+
327+ #delay( ms : number ) : Promise < void > {
328+ return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
329+ }
330+
331+ async #showListbox( ) {
332+ await this . #delay( 10 ) ;
333+ if ( this . value !== '' ) {
334+ this . expanded ||= true ;
335+ }
336+ }
319337}
320338
321339declare global {
0 commit comments