@@ -33,14 +33,14 @@ export class PfSelectChangeEvent extends Event {
3333@customElement ( 'pf-search-input' )
3434export class PfSearchInput extends LitElement {
3535 static readonly styles : CSSStyleSheet [ ] = [ styles ] ;
36-
3736 static readonly formAssociated = true ;
38-
3937 static override readonly shadowRootOptions : ShadowRootInit = {
4038 ...LitElement . shadowRootOptions ,
4139 delegatesFocus : true ,
4240 } ;
4341
42+ static instances : Set < PfSearchInput > = new Set < PfSearchInput > ( ) ;
43+
4444 optionDetails : {
4545 text : string ;
4646 value : string ;
@@ -207,15 +207,23 @@ export class PfSearchInput extends LitElement {
207207 setItemSelected : ( item , selected ) => item . selected = selected ,
208208 } ) ;
209209
210+ static {
211+ document . addEventListener ( 'click' , event => {
212+ for ( const instance of PfSearchInput . instances ) {
213+ instance . _onOutsideClick ( event ) ;
214+ }
215+ } ) ;
216+ }
217+
210218 connectedCallback ( ) : void {
211219 super . connectedCallback ( ) ;
212- document . addEventListener ( 'click' , this . _onOutsideClick ) ;
220+ PfSearchInput . instances . add ( this ) ;
213221 this . addOptions ( this . optionDetails ) ;
214222 }
215223
216224 disconnectedCallback ( ) : void {
217225 super . disconnectedCallback ( ) ;
218- document . removeEventListener ( 'click' , this . _onOutsideClick ) ;
226+ PfSearchInput . instances . delete ( this ) ;
219227 }
220228
221229 // Function to handle the closing of popover
0 commit comments