question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Clicking elements outside Dialogs closes dialog

See original GitHub issue

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 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} />

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 help

Related issues https://github.com/tailwindlabs/headlessui/issues/780 https://github.com/tailwindlabs/headlessui/issues/432

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

7reactions
aquaticonecommented, Feb 24, 2022

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.

3reactions
peterKaletacommented, Mar 17, 2022

@RobinMalfait I’ll agree with @michael-vasyliv here. The <Portal> solution is not really usable across bigger projects with generic use of react-toastify. The mousedown/implicit passing of closing method sounds good.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found