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

Fix Dialog usage in Tabs #1149

Merged
merged 2 commits into from
Feb 24, 2022
Merged

Conversation

RobinMalfait
Copy link
Member

Initially I thought that our open/closed internal state was conflicting between the Tab and Dialog. But that isn't the case at all.

The issue is in the focus trap currently we are collecting the restoreElement even if the focus trap is not enabled. When we unmount we try to restore it.

The problem is the moment you unmount you want to restore but only if the focus trap was enabled.

Another issue is that the dialog state will be closed before we get to the onUmount hook. So there is probably a cleaner way to fix this, but this does the trick as well where we only record the restoreElement the moment the focus trap gets enabled.

Fixes: #1100

Currently we are collecting the `restoreElement` even if the focus trap
is not enabled. When we unmount we try to restore it.

The problem is the moment you unmount you want to restore but only if
the focus trap was enabled.

Another issue is that the dialog state will be `closed` before we get to
the `onUmount` hook. So there is probably a cleaner way to fix this, but
this does the trick as well where we only record the restoreElement the
moment the focus trap gets enabled.
@vercel
Copy link

vercel bot commented Feb 24, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

headlessui-vue – ./packages/playground-vue

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/CadjjbPUHVLnEuapDBZsBfp5eLL9
✅ Preview: https://headlessui-vue-git-ensure-tabs-and-dialog-w-908ec1-tailwindlabs.vercel.app

headlessui-react – ./packages/playground-react

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/DMU15hcoqk1qmt3Cz3tdF1Gf3vgW
✅ Preview: https://headlessui-react-git-ensure-tabs-and-dialog-c3514d-tailwindlabs.vercel.app

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.

Can't change tab with Dialog inside of TabPanel
1 participant