File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -312,14 +312,18 @@ const MultiselectHierarchicalMenuItem = ({
312
312
313
313
const onButtonClick = useCallback ( ( ) => {
314
314
if ( isOpen ) {
315
- // Clear all refinements
316
- levels . forEach ( level => {
317
- level . items . forEach ( subItem => {
318
- if ( subItem . isRefined ) {
319
- level . refine ( subItem . name )
320
- }
321
- } )
322
- } )
315
+ const currentLevel = levels [ index ]
316
+ const subLevel = levels [ index + 1 ]
317
+ if ( item . isRefined ) {
318
+ currentLevel . refine ( item . name )
319
+ }
320
+ if ( subLevel ) {
321
+ subLevel . items
322
+ . filter (
323
+ subItem => subItem . name . startsWith ( item . name ) && subItem . isRefined
324
+ )
325
+ . forEach ( subItem => subLevel . refine ( subItem . name ) )
326
+ }
323
327
}
324
328
setIsOpen ( ! isOpen )
325
329
} , [ isOpen , levels ] )
You can’t perform that action at this time.
0 commit comments