Open ridvanonal opened 3 weeks ago
It's easy to do that you need to state variable isMenuOpenbar which control it
export default function MenubarWithContextMenu() {
const [isMenubarOpen, setIsMenubarOpen] = React.useState(false)
return (
<Menubar>
<MenubarMenu>
<MenubarTrigger onClick={() => setIsMenubarOpen(true)}>File</MenubarTrigger>
<MenubarContent onPointerDownOutside={(e) => e.preventDefault()} forceMount={isMenubarOpen}>
<MenubarItem>
New Tab <MenubarShortcut>⌘T</MenubarShortcut>
</MenubarItem>
<MenubarItem>New Window</MenubarItem>
<MenubarSeparator />
<ContextMenu>
<ContextMenuTrigger asChild>
<MenubarItem>
Share
</MenubarItem>
</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem>Email link</ContextMenuItem>
<ContextMenuItem>Copy link</ContextMenuItem>
</ContextMenuContent>
</ContextMenu>
<MenubarSeparator />
<MenubarItem>Print...</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
)
}
Describe the bug
When I use a context menu within the menu bar, when the context menu closes, the menu bar content also closes, or when I open the context menu again, the menubar content closes again.
Actually, there is no problem in its operation, but when I click outside, only the context menu should close.
Affected component/components
ContextMenu
How to reproduce
When I use a context menu within the menu bar, when the context menu closes, the menu bar content also closes, or when I open the context menu again, the menubar content closes again.
Actually, there is no problem in its operation, but when I click outside, only the context menu should close.
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
Before submitting