@@ -148,9 +148,11 @@ export class PfSearchInput extends LitElement {
148148 const hideLightDomItems = ! ComboboxController . supportsCrossRootActiveDescendant ;
149149
150150 return html `
151- < div id ="outer "
152- style ="${ styleMap ( styles ) } "
153- class ="${ classMap ( { disabled, expanded, [ anchor ] : ! ! anchor , [ alignment ] : ! ! alignment } ) } ">
151+ < div
152+ id ="outer "
153+ style ="${ styleMap ( styles ) } "
154+ class ="${ classMap ( { disabled, expanded, [ anchor ] : ! ! anchor , [ alignment ] : ! ! alignment } ) } "
155+ >
154156 < div id ="toggle ">
155157 < div class ="search-icon ">
156158 < svg fill ="currentColor " height ="1em " width ="1em " viewBox ="0 0 512 512 ">
@@ -167,11 +169,19 @@ export class PfSearchInput extends LitElement {
167169 </ path >
168170 </ svg >
169171 </ div >
170- < input id ="toggle-input "
171- ?disabled ="${ disabled } "
172- placeholder ="${ placeholder || this . #buttonLabel} ">
173-
174- < pf-button id ="toggle-button " plain label ="Close ">
172+ < input
173+ id ="toggle-input "
174+ ?disabled ="${ disabled } "
175+ placeholder ="${ placeholder || this . #buttonLabel} "
176+ >
177+ < button style ="width: 0px; height: 0px; padding: 0px; visibility: hidden; " id ="toggle-button "> </ button >
178+ < pf-button
179+ @click ="${ this . #OnClose} "
180+ ?hidden ="${ ( ! expanded && this . _toggleInput ?. value . trim ( ) === "" ) } "
181+ id ="close-button "
182+ plain
183+ label ="Close "
184+ >
175185 < svg fill ="currentColor " height ="1em " width ="1em " viewBox ="0 0 352 512 ">
176186 < path d ="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19
177187 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176
@@ -181,17 +191,18 @@ export class PfSearchInput extends LitElement {
181191 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28
182192 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z ">
183193 </ path >
184- </ svg >
185- </ pf-button >
194+ </ svg >
195+ </ pf-button >
186196 </ div >
187- < div id ="listbox-container "
188- ?hidden ="${ ! expanded } "
189- style ="${ styleMap ( {
190- marginTop : `${ height || 0 } px` ,
191- width : width ? `${ width } px` : 'auto' ,
192- } ) } ">
197+ < div
198+ id ="listbox-container "
199+ ?hidden ="${ ! expanded } "
200+ style ="${ styleMap ( {
201+ marginTop : `${ height || 0 } px` ,
202+ width : width ? `${ width } px` : 'auto' ,
203+ } ) } "
204+ >
193205 < div id ="listbox ">
194-
195206 ${ this . #combobox. renderItemsToShadowRoot ( ) }
196207 < slot ?hidden ="${ hideLightDomItems } "> </ slot >
197208 </ div >
@@ -288,6 +299,14 @@ export class PfSearchInput extends LitElement {
288299 await this . show ( ) ;
289300 }
290301 }
302+
303+ async #OnClose( ) {
304+ if ( this . expanded ) {
305+ await this . hide ( ) ;
306+ }
307+ this . value = "" ;
308+ this . _toggleInput ! . value = this . value ;
309+ }
291310}
292311
293312declare global {
0 commit comments