@@ -19,6 +19,7 @@ import { observes } from '@patternfly/pfe-core/decorators/observes.js';
1919import { PfSearchInputOption } from './pf-search-input-option.js' ;
2020import styles from './pf-search-input.css' ;
2121import type { PfButton } from '../pf-button/pf-button.js' ;
22+ import { bound } from '@patternfly/pfe-core/decorators.js' ;
2223
2324export class PfSelectChangeEvent extends Event {
2425 constructor ( ) {
@@ -84,6 +85,8 @@ export class PfSearchInput extends LitElement {
8485
8586 @query ( '#placeholder' ) private _placeholder ?: PfSearchInputOption ;
8687
88+ @query ( '#outer' ) private _searchInputContainer ! : HTMLElement ;
89+
8790 #isNotPlaceholderOption = ( option : PfSearchInputOption ) => option !== this . _placeholder ;
8891
8992 #internals = InternalsController . of ( this ) ;
@@ -110,6 +113,29 @@ export class PfSearchInput extends LitElement {
110113 setItemSelected : ( item , selected ) => item . selected = selected ,
111114 } ) ;
112115
116+ connectedCallback ( ) : void {
117+ super . connectedCallback ( ) ;
118+ document . addEventListener ( 'click' , this . _onOutsideClick ) ;
119+ }
120+
121+ disconnectedCallback ( ) : void {
122+ super . disconnectedCallback ( ) ;
123+ document . removeEventListener ( 'click' , this . _onOutsideClick ) ;
124+ }
125+
126+
127+ // Function to handle the closing of popover and month select popup on outside click
128+ @bound private _onOutsideClick ( event : MouseEvent ) {
129+ const path = event . composedPath ( ) ;
130+ if ( ! path . includes ( this . _searchInputContainer ) ) {
131+ if ( this . expanded ) {
132+ this . expanded = false ;
133+ } else {
134+ //this._popover.hide();
135+ }
136+ }
137+ }
138+
113139 /**
114140 * Single select option value for single select menus,
115141 * or array of select option values for multi select.
0 commit comments