Skip to content

v9 - How to open a Dialog from MenuItem? #28411

Answered by behowell
Pistonight asked this question in Q&A
Discussion options

You must be logged in to vote

I believe you can start with the "Trigger outside dialog" example from the dialog documentation, and use the MenuItem as the trigger: https://react.fluentui.dev/?path=/docs/components-dialog--default#trigger-outside-dialog. You'll need to control the dialog's open prop. And because you're not using the DialogTrigger component, you need to manually restore focus to the button that opened the menu when the dialog closes.

Here's a demo codesandbox: https://codesandbox.io/s/dialog-opened-by-menuitem-3ctlff?file=/example.tsx

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by behowell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants