@@ -27,6 +27,9 @@ export type ComboboxInputs<T extends ListItem<V>, V> = {
2727
2828 /** The filtering mode for the combobox. */
2929 filterMode : SignalLike < 'manual' | 'auto-select' | 'highlight' > ;
30+
31+ /** The function used to filter items in the combobox. */
32+ filter : SignalLike < ( inputText : string , itemText : string ) => boolean > ;
3033} ;
3134
3235/** An interface that allows combobox popups to expose the necessary controls for the combobox. */
@@ -189,6 +192,19 @@ export class ComboboxPattern<T extends ListItem<V>, V> {
189192 }
190193 }
191194
195+ setDefaultState ( ) {
196+ if ( this . inputs . value ( ) !== undefined ) {
197+ this . inputs . popupControls ( ) ?. setValue ( this . inputs . value ( ) ) ;
198+
199+ const inputEl = this . inputs . inputEl ( ) ;
200+ const searchTerm = this . inputs . popupControls ( ) ?. getSelectedItem ( ) ?. searchTerm ( ) ?? '' ;
201+
202+ if ( inputEl ) {
203+ inputEl . value = searchTerm ;
204+ }
205+ }
206+ }
207+
192208 /** Closes the combobox. */
193209 close ( ) {
194210 this . expanded . set ( false ) ;
@@ -223,7 +239,7 @@ export class ComboboxPattern<T extends ListItem<V>, V> {
223239 . startsWith ( this . searchString ( ) . toLowerCase ( ) ) ;
224240
225241 if ( element && isHighlightable ) {
226- element . value = item . searchTerm ( ) ;
242+ element . value = this . searchString ( ) + item . searchTerm ( ) . slice ( this . searchString ( ) . length ) ;
227243 element . setSelectionRange ( this . searchString ( ) . length , item . searchTerm ( ) . length ) ;
228244 this . highlightedItem . set ( item ) ;
229245 }
0 commit comments