Opening a dialog from a context menu #2274
Unanswered
brianlovin
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey team! I've spent some time today trying to figure out how to open a dialog from a context menu, but the way focus works with Radix makes it quite tricky.
Specifically, the problem is:
body
gets locked with the forcedpointer-events: none
inline styleI found this example where a dropdown can open a dialog: https://codesandbox.io/s/dropdownmenu-dialog-items-r9sq1q?file=/src/App.js:5148-5255
And this example where a context menu can focus another element, like an input: https://codesandbox.io/s/contextmenu-custom-focus-on-action-28e6cl?file=/src/App.js:478-541
But each of these approaches requires overhead with managing focus states and passing refs around. It also makes it hard to abstract out a
ContextMenu
component that has some common styles and behaviors, where certain actions in that context menu might invoke a function, or others might invoke a dialog.Does anyone have ideas on how to simplify this?
This is loosely the kind of abstraction I'd love to end up with, but so far it seems impossible with how focus management works:
So far I've tried putting this on my
ContextMenu.Content
component:Beta Was this translation helpful? Give feedback.
All reactions