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

Ensure unmount on Dialog works in combination with the transition prop on DialogBackdrop and DialogPanel components #3352

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

RobinMalfait
Copy link
Member

Only the Dialog accepts an unmount prop because it's the Dialog that is conditionally rendered and the DialogBackdrop and DialogPanel will conditionally show together with the Dialog.

However, now that the Dialog is wrapped in a Transition (which can be unmounted) and the DialogBackdrop and DialogPanel will also be wrapped in a TransitionChild (when the transition prop is passed) then we do have to deal with the unmount state on the TransitionChild.

This is important because if you make the Dialog unmount={false}, then the DialogPanel will still unmount because the TransitionChild is unmounting its children. This now means that you will lose data (such as form state of inputs).

This PR solves that by inheriting the unmount state of the Dialog in the TransitionChild wrappers such that they behave the way you expect them to behave.

Fixes: #3348

… components

Only the `Dialog` accepts an `unmount` prop because it's the `Dialog`
that is conditionally rendered and the `DialogBackdrop` and
`DialogPanel` will conditionally show together with the `Dialog`.

However, now that the `Dialog` is wrapped in a `Transition` (which can
be unmounted) and the `DialogBackdrop` and `DialogPanel` will also be
wrapped in a `TransitionChild` (when the `transition` prop is passed)
then we do have to deal with the `unmount` state on the `TransitionChild`.

This is important because if you make the `Dialog` `unmount={false}`, then the
`DialogPanel` will still unmount because the `TransitionChild` is unmounting its
children. This now means that you will lose data (such as form state of inputs).

This commit solves that by inheriting the `unmount` state of the
`Dialog` in the `TransitionChild` wrappers such that they behave the way
you expect them to behave.
Copy link

vercel bot commented Jul 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 0:29am
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 0:29am

@RobinMalfait RobinMalfait merged commit 990b179 into main Jul 1, 2024
8 checks passed
@RobinMalfait RobinMalfait deleted the fix/issue-3348 branch July 1, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<Dialog> won't open when unmount is set to false
2 participants