Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.

Commit 54aa03e

Browse files
authored
fix(menubar): clicking submenu header inside dropdown (#8175)
1 parent 9ac1c0f commit 54aa03e

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

components/lib/menubar/Menubar.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ export const Menubar = React.memo(
4242
const [bindOutsideClickListener, unbindOutsideClickListener] = useEventListener({
4343
type: 'click',
4444
listener: (event) => {
45-
const isOutsideButton = menuButtonRef.current && !menuButtonRef.current.contains(event.target);
45+
if (isOutsideClicked(event)) {
46+
const isOutsideContainer = elementRef.current && !elementRef.current.contains(event.target);
4647

47-
if (isOutsideButton) {
48-
hide();
48+
if (isOutsideContainer) {
49+
hide();
50+
}
4951
}
5052
},
5153
options: { capture: true }
@@ -98,6 +100,10 @@ export const Menubar = React.memo(
98100
(event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Space') && toggle(event);
99101
};
100102

103+
const isOutsideClicked = (event) => {
104+
return rootMenuRef.current !== event.target && !rootMenuRef.current.contains(event.target) && menuButtonRef.current !== event.target && !menuButtonRef.current.contains(event.target);
105+
};
106+
101107
const getItemProp = (item, name) => {
102108
return item ? ObjectUtils.getItemValue(item[name]) : undefined;
103109
};

0 commit comments

Comments
 (0)