-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Bug]: Clicking elements outside Dialogs closes dialog #1138
Comments
Hey! Thank you for your bug report! The Portal solution only works if you are in control of rendering the toast yourself AND if you render the Portal as part of the Dialog. Here is an updated codesandbox: https://codesandbox.io/s/lucid-hugle-vn8w52?file=/src/App.js The Portal itself will still render it in the DOM in a portal root right underneath the |
@RobinMalfait thank you for the idea but it does not help for a "real project", the problem is that basically |
I'd also like to be able to disable the There are a number of scenarios in which this global handling is problematic, including toasts. |
Hello 👋🏻 , any news on this issue ? I have the same problem using the date-picker in |
@RobinMalfait I'll agree with @michael-vasyliv here. The |
Was running into the same problem except for a custom notification/toast component and found a solution that's working well for my app. I added a check to the Depending on your app, you'll need to change the if statement, but hopefully it gives you an idea of how to solve this while still retaining the nice parts of detecting click outside. <Dialog ...
onClose={(val) => {
// Don't close if clicked on a notification
if (event.path.some((elem) => elem.classList?.contains("notification"))) {
return null
}
setOpen(val)
}
...></Dialog> |
@connorlindsey @RobinMalfait |
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
1.5.0
What browser are you using?
Chrome
Reproduction URL
https://n797o6.csb.app/
Describe your issue
Scenario: We have a HeadlessUI
Dialog
andreact-toastify
. When a dialog is open we click on a notification to close it but it also closes the dialog.In my opinion, it will be easy to remove/disable this listener and just use this
https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/components/dialog/dialog.tsx#L210
I've tried the solution with
Portal
but it didn't helpRelated issues
#780
#432
The text was updated successfully, but these errors were encountered: