Skip to content

[bug]: AlertDialog and DropdownMenu Integration in Radix UI #7124

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

Open
2 tasks done
Romain-josepavel opened this issue Apr 4, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Romain-josepavel
Copy link

Describe the bug

Issue with AlertDialog and DropdownMenu Integration in Radix UI

When integrating an AlertDialog inside a DropdownMenu from Radix UI, you might encounter an issue where the AlertDialog doesn't close correctly. This can result in a scenario where the event pointer is stuck and empty, preventing the user from interacting with the page. The cause of this is that the DropdownMenu takes focus and prevents the AlertDialog from closing as expected.

Solution

To fix this, you need to set the modal={false} property on the Radix UI DropdownMenu component. This allows the DropdownMenu to function properly and ensures that the AlertDialog can close as intended when the user interacts with it.

Example

<DropdownMenu modal={false}>
  {/* Menu content */}
  <AlertDialog>
    {/* Alert dialog content */}
  </AlertDialog>
</DropdownMenu>

or

const DropdownMenu = ({ ...rest }) => (
  <DropdownMenuPrimitive.Root modal={false} {...rest} />
)

Suggestion

To prevent developers from running into this issue, it would be helpful to either set modal={false} by default in the integration of DropdownMenu with the AlertDialog, or to add this information to the official ShadCN documentation. This would help developers understand this behavior and avoid the issue without having to search for a solution.

Affected component/components

AlertDialogue, Dropdowm Menu

How to reproduce

Integrate an alert Dialogue into a dropdown menu.
open the dropdown menu
open the dialogue -> dropdown closing automatically
close the dialogue

Codesandbox/StackBlitz link

No response

Logs

System Info

Browers

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@Romain-josepavel Romain-josepavel added the bug Something isn't working label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant