[Bug]: Clicking elements outside Dialogs closes dialog
See original GitHub issueWhat 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
and react-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
<Dialog.Overlay className="fixed inset-0 bg-black bg-opacity-50" onClick={closeThisDialogWithoutAnyFckPain} />
I’ve tried the solution with Portal
but it didn’t help
Related issues https://github.com/tailwindlabs/headlessui/issues/780 https://github.com/tailwindlabs/headlessui/issues/432
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Clicking outside of the flag/close dialog should not dismiss the ...
The behavior is certainly annoying but nothing that could not be solved without a userscript. Below is a script that preserves text entered ......
Read more >Windows 7 Dialog Boxes (Design basics) - Win32 apps
For modeless dialogs, use an explicit Close command button in the dialog to close the window. For both, use a Close button on...
Read more >Dialogs | Aurelia
Accessing The DialogController API. It is possible to resolve and close (using cancel/ok/error methods) dialog in the same context where you open it....
Read more >Dialog component — Vuetify
Dialogs. The v-dialog component inform users about a specific task ... that it's not dismissed when touching outside or pressing esc key.
Read more >Modal - Ant Design
maskClosable, Whether to close the modal dialog when the mask (area outside the modal) is clicked, boolean, false ; maskStyle, Style for modal's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d also like to be able to disable the
mousedown
event handler.There are a number of scenarios in which this global handling is problematic, including toasts.
@RobinMalfait I’ll agree with @michael-vasyliv here. The
<Portal>
solution is not really usable across bigger projects with generic use ofreact-toastify
. The mousedown/implicit passing of closing method sounds good.