Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit f869f9f

Browse files
boilundTigge
authored andcommitted
fix(menu): prevent closing menu when you click an item that has a submenu
1 parent 7f77f10 commit f869f9f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/core/src/Menu/BaseMenu.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ const BaseItemWithSubmenu: React.FunctionComponent<
422422
e.preventDefault()
423423
}, [])
424424

425+
const preventCloseMenu = useCallback(e => {
426+
// Prevent event from bubbling up to the wrapper
427+
// that closes the menu when it has submenu
428+
e.stopPropagation()
429+
}, [])
430+
425431
return (
426432
<>
427433
<BaseMenuItem
@@ -431,6 +437,7 @@ const BaseItemWithSubmenu: React.FunctionComponent<
431437
onPointerDown={preventMenuBlur}
432438
onPointerOver={show}
433439
onPointerOut={hide}
440+
onClick={preventCloseMenu}
434441
>
435442
{component}
436443
</BaseMenuItem>

0 commit comments

Comments
 (0)