@@ -27,6 +27,9 @@ export type ComboboxInputs<T extends ListItem<V>, V> = {
27
27
28
28
/** The filtering mode for the combobox. */
29
29
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 > ;
30
33
} ;
31
34
32
35
/** 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> {
189
192
}
190
193
}
191
194
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
+
192
208
/** Closes the combobox. */
193
209
close ( ) {
194
210
this . expanded . set ( false ) ;
@@ -223,7 +239,7 @@ export class ComboboxPattern<T extends ListItem<V>, V> {
223
239
. startsWith ( this . searchString ( ) . toLowerCase ( ) ) ;
224
240
225
241
if ( element && isHighlightable ) {
226
- element . value = item . searchTerm ( ) ;
242
+ element . value = this . searchString ( ) + item . searchTerm ( ) . slice ( this . searchString ( ) . length ) ;
227
243
element . setSelectionRange ( this . searchString ( ) . length , item . searchTerm ( ) . length ) ;
228
244
this . highlightedItem . set ( item ) ;
229
245
}
0 commit comments