@@ -17,7 +17,6 @@ import { arraysAreEquivalent } from '@patternfly/pfe-core/functions/arraysAreEqu
1717import { observes } from '@patternfly/pfe-core/decorators/observes.js' ;
1818import { PfOption } from '../pf-select/pf-option.js' ;
1919import { bound } from '@patternfly/pfe-core/decorators.js' ;
20- import '@patternfly/elements/pf-text-input/pf-text-input.js' ;
2120import styles from './pf-search-input.css' ;
2221
2322export class PfSearchChangeEvent extends Event {
@@ -83,8 +82,6 @@ export class PfSearchInput extends LitElement {
8382
8483 @query ( '#outer' ) private _searchInputContainer ! : HTMLElement ;
8584
86- // #isNotPlaceholderOption = (option: PfOption) => option !== this._placeholder;
87-
8885 #internals = InternalsController . of ( this ) ;
8986
9087 #float = new FloatingDOMController ( this , { content : ( ) => this . _listboxContainer } ) ;
@@ -172,51 +169,46 @@ export class PfSearchInput extends LitElement {
172169 const hideLightDomItems = ! ComboboxController . supportsCrossRootActiveDescendant ;
173170
174171 return html `
175- < div class ="search-input-container ">
176- < div
177- id ="outer "
178- style ="${ styleMap ( styles ) } "
179- class ="${ classMap ( { disabled, expanded, [ anchor ] : ! ! anchor , [ alignment ] : ! ! alignment } ) } "
180- >
181- < div id ="toggle ">
182- < div class ="search-icon ">
183- < pf-icon size ="md " icon ="search " set ="fas "> search</ pf-icon >
184- </ div >
185- < input
186- id ="toggle-input "
187- ?disabled ="${ disabled } "
188- @keydown =${ this . #onSearchInput}
189- placeholder ="${ placeholder } ">
190- < div class ="close-button-container ">
191- < pf-button
192- @click ="${ this . #OnClose} "
193- ?hidden ="${ this . #hideCloseButton( ) } "
194- id ="close-button "
195- plain
196- label ="Close "
197- >
198- < pf-icon size ="md " icon ="close " set ="patternfly "> close</ pf-icon >
199- </ pf-button >
200- </ div >
201- < button aria-label ="toggle button " inert class ="visually-hidden " id ="toggle-button "> </ button >
172+ < div
173+ id ="outer "
174+ style ="${ styleMap ( styles ) } "
175+ class ="${ classMap ( { disabled, expanded, [ anchor ] : ! ! anchor , [ alignment ] : ! ! alignment } ) } "
176+ >
177+ < div id ="toggle ">
178+ < div class ="search-icon ">
179+ < pf-icon size ="md " icon ="search " set ="fas "> search</ pf-icon >
202180 </ div >
203- < div
204- id ="listbox-container "
205- ?hidden ="${ ! expanded } "
206- style ="${ styleMap ( {
207- marginTop : `${ height || 0 } px` ,
208- width : width ? `${ width } px` : 'auto' ,
209- } ) } "
181+ < input
182+ id ="toggle-input "
183+ ?disabled ="${ disabled } "
184+ @change =${ this . #onChange}
185+ @keyup =${ this . #onSubmit}
186+ placeholder="${ placeholder } "
210187 >
211- < div id ="listbox ">
212- ${ this . #combobox. renderItemsToShadowRoot ( ) }
213- < slot ?hidden ="${ hideLightDomItems } "> </ slot >
214- </ div >
188+ < div class ="close-button-container ">
189+ < pf-button
190+ @click ="${ this . #OnClose} "
191+ ?hidden ="${ this . #hideCloseButton( ) } "
192+ id ="close-button "
193+ plain
194+ label ="Close "
195+ >
196+ < pf-icon size ="md " icon ="close " set ="patternfly "> close</ pf-icon >
197+ </ pf-button >
215198 </ div >
199+ < button aria-label ="toggle button " inert class ="visually-hidden " id ="toggle-button "> </ button >
216200 </ div >
217- < div @click =${ this . #onSubmit} @keydown =${ this . #handleKeyDown}
218- class="submit-button-container">
219- < slot name ="submit "> </ slot >
201+ < div
202+ id ="listbox-container "
203+ ?hidden ="${ ! expanded } "
204+ style ="${ styleMap ( {
205+ marginTop : `${ height || 0 } px` ,
206+ width : width ? `${ width } px` : 'auto' ,
207+ } ) } ">
208+ < div id ="listbox ">
209+ ${ this . #combobox. renderItemsToShadowRoot ( ) }
210+ < slot ?hidden ="${ hideLightDomItems } "> </ slot >
211+ </ div >
220212 </ div >
221213 </ div >
222214 ` ;
@@ -252,7 +244,6 @@ export class PfSearchInput extends LitElement {
252244 this . dispatchEvent ( new PfSearchChangeEvent ( ) ) ;
253245 }
254246
255-
256247 async #doExpand( ) {
257248 try {
258249 await this . #float. show ( { placement : this . position || 'bottom' , flip : ! ! this . enableFlip } ) ;
@@ -314,34 +305,17 @@ export class PfSearchInput extends LitElement {
314305 return false ;
315306 }
316307
317- #onSearchInput( event : KeyboardEvent ) {
318- if ( event . key === 'Enter' || event . key === ' ' ) {
319- this . value = this . _toggleInput ?. value ;
320- this . #internals. setFormValue ( this . value ?? '' ) ;
321- this . dispatchEvent ( new PfSearchChangeEvent ( ) ) ;
322- }
308+ #onChange( event : Event ) {
309+ this . value = this . _toggleInput ?. value ;
310+ this . #internals. setFormValue ( this . value ?? '' ) ;
311+ this . dispatchEvent ( new PfSearchChangeEvent ( ) ) ;
323312 }
324313
325- #onSubmit( event : MouseEvent | KeyboardEvent ) {
326- const path = event . composedPath ( ) ;
327- const slottedSearchButton = path . find ( el =>
328- el instanceof HTMLElement
329- && el . tagName === 'PF-BUTTON'
330- && el . getAttribute ( 'data-action' ) === 'search'
331- ) ;
332-
333- if ( slottedSearchButton && this . _toggleInput ?. value ) {
334- this . value = this . _toggleInput ?. value ;
335- this . #internals. setFormValue ( this . value ?? '' ) ;
314+ #onSubmit( event : KeyboardEvent ) {
315+ if ( event . key === 'Enter' || event . key === ' ' ) {
336316 this . dispatchEvent ( new PfSearchChangeEvent ( ) ) ;
337317 }
338318 }
339-
340- #handleKeyDown( e : KeyboardEvent ) {
341- if ( e . key === 'Enter' || e . key === ' ' ) {
342- this . #onSubmit( e ) ;
343- }
344- }
345319}
346320
347321declare global {
0 commit comments