-
Notifications
You must be signed in to change notification settings - Fork 34
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: click outside <Dialog /> should be allowed #170
Comments
Hello @rreckonerr 👋 So you expect that clicking on blue box it will keep modal opened ? simplescreenrecorder-2022-12-16_10.10.01.mp4 |
I found a relevant test which you described:
Looking at what others folks in topic said, I am not sure that this would be a solution for you issue 🤔 ...
this.toastService.success('message...');
... And magic goes inside service provided by 3th lib. Then still it will close dialog when clicking on toast box 🤔 Your workaround will fail with this test: as we control visibility of modal by passing onClose(event) {
if (event.doesNotComeFromYourToastBox) {
this.isModalOpen = false;
}
} Any chance does it work ? |
Hi, @far-fetched! |
I also have a use case that requires the "click outside" to be disabled for specific events. The event isn't currently being passed to the |
According to the Official API it does not pass event in callback either. Can you show your example (might be simplified) in some sandbox code ? Maybe we can resolve it differently. |
Yes, I'll put something together, thanks. I'm away for a few days now. It's a very basic implementation that renders a form. One of the form inputs is a select that renders its options into a portal. When you select an option it closes the modal prematurely. The only way I can see to prevent this is to check the event - as you suggested above - but I don't have access to it. |
Usecase
I'm working on adding notifications to the app, and it should be possible to click/close the notification without closing the current
<Dialog />
Problem
At the moment any click outside
<Dialog />
will trigger @onclose. The only exception is child dialogs spawned by the modal (handled by dialog-stack-provider service).This behavior used to be the same in
@headlessui/[email protected]
, but since@headlessui/[email protected]
it's possible to click outside the dialog without triggering the @onclose action IF the "outsider" is wrapped with headlessui<Portal />
component.Workaround
As a workaround, I extended the
dialog.js
component as followsResources
@headlessui/[email protected]
can be found here https://codesandbox.io/s/amazing-cerf-82m41d?file=/src/App.js@headlessui/[email protected]
can be found here https://codesandbox.io/s/modern-wave-g3409m?file=/src/App.jsThe text was updated successfully, but these errors were encountered: