@@ -49,10 +49,12 @@ export const MultiselectFilterControl = <TItem,>({
49
49
const withPrefix = ( id : string ) => `${ idPrefix } -${ id } ` ;
50
50
const defaultGroup = category . title ;
51
51
52
- const filteredOptions = category . selectOptions ?. filter ( ( { label, value } ) =>
53
- String ( label ?? value ?? "" )
54
- . toLowerCase ( )
55
- . includes ( inputValue ?. trim ( ) . toLowerCase ( ) ?? "" )
52
+ const filteredOptions = category . selectOptions ?. filter (
53
+ ( { label, value, groupLabel } ) =>
54
+ [ label ?? value , groupLabel ]
55
+ . filter ( Boolean )
56
+ . map ( ( it ) => it . toLocaleLowerCase ( ) )
57
+ . some ( ( it ) => it . includes ( inputValue ?. trim ( ) . toLowerCase ( ) ?? "" ) )
56
58
) ;
57
59
58
60
const [ firstGroup , ...otherGroups ] = [
@@ -64,7 +66,7 @@ export const MultiselectFilterControl = <TItem,>({
64
66
] ) ,
65
67
] ;
66
68
67
- const onFilterClearAll = ( groupName : string ) =>
69
+ const onFilterClearGroup = ( groupName : string ) =>
68
70
setFilterValue (
69
71
filterValue
70
72
?. map ( ( filter ) : [ string , FilterSelectOptionProps | undefined ] => [
@@ -226,12 +228,12 @@ export const MultiselectFilterControl = <TItem,>({
226
228
227
229
return (
228
230
< >
229
- { [
231
+ {
230
232
< ToolbarFilter
231
233
id = { `${ idPrefix } -${ firstGroup } ` }
232
234
chips = { chipsFor ( firstGroup ) }
233
235
deleteChip = { ( _ , chip ) => onFilterClear ( chip ) }
234
- deleteChipGroup = { ( ) => onFilterClearAll ( firstGroup ) }
236
+ deleteChipGroup = { ( ) => onFilterClearGroup ( firstGroup ) }
235
237
categoryName = { firstGroup }
236
238
key = { firstGroup }
237
239
showToolbarItem = { showToolbarItem }
@@ -246,52 +248,50 @@ export const MultiselectFilterControl = <TItem,>({
246
248
isOpen = { isFilterDropdownOpen }
247
249
>
248
250
< SelectList id = { withPrefix ( "select-typeahead-listbox" ) } >
249
- { [
250
- ...filteredOptions . map (
251
- ( { groupLabel, label, value, optionProps = { } } , index ) => (
252
- < SelectOption
253
- { ...optionProps }
254
- { ...( ! optionProps . isDisabled && { hasCheckbox : true } ) }
255
- key = { value }
256
- id = { withPrefix ( `option-${ index } ` ) }
257
- value = { value }
258
- isFocused = { focusedItemIndex === index }
259
- isSelected = { filterValue ?. includes ( value ) }
260
- >
261
- { ! ! groupLabel && < Label > { groupLabel } </ Label > } { " " }
262
- { label ?? value }
263
- </ SelectOption >
264
- )
265
- ) ,
266
- ! filteredOptions . length && (
251
+ { filteredOptions . map (
252
+ ( { groupLabel, label, value, optionProps = { } } , index ) => (
267
253
< SelectOption
268
- isDisabled
269
- hasCheckbox = { false }
270
- key = { NO_RESULTS }
271
- value = { NO_RESULTS }
272
- isSelected = { false }
254
+ { ...optionProps }
255
+ { ...( ! optionProps . isDisabled && { hasCheckbox : true } ) }
256
+ key = { value }
257
+ id = { withPrefix ( `option-${ index } ` ) }
258
+ value = { value }
259
+ isFocused = { focusedItemIndex === index }
260
+ isSelected = { filterValue ?. includes ( value ) }
273
261
>
274
- { `No results found for "${ inputValue } "` }
262
+ { ! ! groupLabel && < Label > { groupLabel } </ Label > } { " " }
263
+ { label ?? value }
275
264
</ SelectOption >
276
- ) ,
277
- ] . filter ( Boolean ) }
265
+ )
266
+ ) }
267
+ { filteredOptions . length === 0 && (
268
+ < SelectOption
269
+ isDisabled
270
+ hasCheckbox = { false }
271
+ key = { NO_RESULTS }
272
+ value = { NO_RESULTS }
273
+ isSelected = { false }
274
+ >
275
+ { `No results found for "${ inputValue } "` }
276
+ </ SelectOption >
277
+ ) }
278
278
</ SelectList >
279
279
</ Select >
280
- </ ToolbarFilter > ,
281
- ... otherGroups . map ( ( groupName ) => (
282
- < ToolbarFilter
283
- id = { ` ${ idPrefix } - ${ groupName } ` }
284
- chips = { chipsFor ( groupName ) }
285
- deleteChip = { ( _ , chip ) => onFilterClear ( chip ) }
286
- deleteChipGroup = { ( ) => onFilterClearAll ( groupName ) }
287
- categoryName = { groupName }
288
- key = { groupName }
289
- showToolbarItem = { false }
290
- >
291
- { " " }
292
- </ ToolbarFilter >
293
- ) ) ,
294
- ] }
280
+ </ ToolbarFilter >
281
+ }
282
+ { otherGroups . map ( ( groupName ) => (
283
+ < ToolbarFilter
284
+ id = { ` ${ idPrefix } - ${ groupName } ` }
285
+ chips = { chipsFor ( groupName ) }
286
+ deleteChip = { ( _ , chip ) => onFilterClear ( chip ) }
287
+ deleteChipGroup = { ( ) => onFilterClearGroup ( groupName ) }
288
+ categoryName = { groupName }
289
+ key = { groupName }
290
+ showToolbarItem = { false }
291
+ >
292
+ { " " }
293
+ </ ToolbarFilter >
294
+ ) ) }
295
295
</ >
296
296
) ;
297
297
} ;
0 commit comments