-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opening a Dialog programmatically from a Dropdown Menu item freezes the UI #3317
Comments
When you are using components that uses an overlay such as dropdown or dialog. Make sure to sync the versions of dialog and dropdown that you have to x.x.4 |
I was trying to open a sheet in a select in shadcn/ui - they are components made with select and dialog in radix-ui and I had exactly the same problem. I followed @FredrikMWold's solution to make everything in radix-ui up to date and it works! |
We have the same problem.
We still can reproduce the issue. |
Just adding a datapoint here. I have multiple projects in which this has happened. In some, upgrading & aligning versions of @radix-ui/* packages worked. In others, I had to resort to using workarounds such as clearing |
Experiencing the same with latest |
If just updating did not help. Then I recommend deleting node_modules and reinstalling. |
Bug report
Current Behavior
This is very specific, but I want to open a Dialog programmatically by clicking on a Dropdown menu item.
Basically,
body
gets stuck withpointer-events: none
after closing the modal.Expected behavior
After closing the modal,
body
should not havepointer-events: none
set.Reproducible example
[https://codesandbox.io/p/devbox/condescending-thunder-fdtprf](Codesandbox Repro)
Suggested solution
My solution was delaying the opening of the modal to the next cycle via
setTimeout(() => { setOpen(true); }, 0);
, but this feels kind of kludgy.The issue probably has to do with two conflicting underlying
DismissableLayer
s messing with each other, esp. with regards to originalBodyPointerEvents. My guess is that when Dialog mounts, because of DropdownMenu not having its cleanup effect run, body still haspointer-events: none
set, so that's what Dialog thinks is the properoriginalBodyPointerEvents
. When the Dialog unmounts.. it "resets" to that value -pointer-events: none
.I know this is an edge case, and I'm not sure if there is actually a robust solution to this besides just manually handling it the way I did (besides having some sort of system to maintain a "stack" of
pointer-event
values, which would probably require wrapping the components in a wrapper context... bleh).But I thought I would just throw this out there in case someone has a better idea.
The text was updated successfully, but these errors were encountered: