Skip to content
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] Dialog.Overlay doesn't close together with Dialog on latest main commit (591b328) #1351

Closed
spvn opened this issue Apr 21, 2022 · 6 comments

Comments

@spvn
Copy link

spvn commented Apr 21, 2022

What package within Headless UI are you using?

@headlessui/react@insiders.591b328

What browser are you using?

Firefox

Describe your issue

Not sure if it's only affecting me, but I'm using the current insiders version and Dialog.Overlay stays visible even when you close the Dialog it belongs to, blocking inputs to the underlying page. I reverted to commit ab6310 and this issue went away, but it also resulted in issues with using datepickers in modals (i.e. the fix that was supposed to come with this pull request doesn't work, and clicking inside a datepicker in a dialog will cause the dialog to close. #1268).

EDIT: I have come to realise that strangely, this bug only happens IF you have an opacity class on the Dialog.Overlay component. For example the overlay closes if it looks like that:

<Dialog.Overlay className="fixed inset-0 bg-black"/>

but does NOT close if it's like that:

<Dialog.Overlay className="fixed inset-0 bg-black opacity-30"/>

I'm using a Transition for this overlay just like in this codesandbox that was posted when fixing #432

After some further testing, removing the surrounding tag fixes the issue, so there's probably some conflict with transitioning the opacity.

@spvn spvn changed the title Dialog.Overlay doesn't close together with Dialog on latest main commit (591b328) [Bug] Dialog.Overlay doesn't close together with Dialog on latest main commit (591b328) Apr 21, 2022
@RobinMalfait
Copy link
Collaborator

Hey! Thank you for your bug report!
Much appreciated! 🙏

Please provide a reproduction repo or CodeSandbox so that we can take a look.

@spvn
Copy link
Author

spvn commented Apr 21, 2022

Will create one when I'm free, but just FYI the sample code for Dialog on the website will break. I'm referring to the sample dialog at the top of this page: https://headlessui.dev/react/dialog

Removing as={Fragment} from Dialog.Overlay's <Transition.Child> fixes the problem

@grefrit
Copy link

grefrit commented Apr 21, 2022

Can confirm that dialog doesn't close on 591b328 when using with Transition component, but it's working in b4a4e0b

EDIT: Really strange that I reverted to b4a4e0b and Dialog start working properly, but I'm using Popover in Dialog and that Popover actually inside Portal and when I'm clicking on the Popover, Dialog just closes(in 591b328 Popover is working properly, in b4a4e0b Dialog is working properly) :)

@RobinMalfait
Copy link
Collaborator

@grefrit can you create a reproduction repo / CodeSandbox and share it?

@RobinMalfait
Copy link
Collaborator

Hey!

Going to close this for now, if you still have this issue please create a new issue with a reproduction repo / CodeSandbox attached.

@stupeyca
Copy link

Removing as={Fragment} from Dialog.Overlay's <Transition.Child> fixes the problem

This solved the issue on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants