Is it possible to use a menu item as a dialog trigger? #5729
-
Hi everyone, I was wondering, does React Aria support using a menu item as a dialog trigger? The documentation doesn't seem to mention this use case. For example... <MenuTrigger>
<Button aria-label="Menu">☰</Button>
<Popover>
<Menu onAction={alert}>
<DialogTrigger>
<MenuItem id="open">Open Dialog</MenuItem>
{(close) => <Dialog>Hello</Dialog>}
</DialogTrigger>
<MenuItem id="second">Item 2</MenuItem>
</Menu>
</Popover>
</MenuTrigger> Any help would be much appreciated. Thank you 🙇 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This API isn't currently supported due to the types of children Menu expects, but you can always do this in a controlled way. Here is the example from the React Aria homepage where the edit and delete items open up dialogs: react-spectrum/packages/dev/docs/pages/react-aria/home/ExampleApp.tsx Lines 246 to 247 in ee51290 |
Beta Was this translation helpful? Give feedback.
This API isn't currently supported due to the types of children Menu expects, but you can always do this in a controlled way. Here is the example from the React Aria homepage where the edit and delete items open up dialogs:
react-spectrum/packages/dev/docs/pages/react-aria/home/ExampleApp.tsx
Lines 246 to 247 in ee51290