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 invalid warning when using multiple Popover.Button components inside a Popover.Panel #2333

Merged
merged 3 commits into from
Mar 3, 2023

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Mar 3, 2023

This PR fixes an incorrect warning that complained about using multiple Popover.Button components. However this is valid inside the Popover.Panel itself, just not the Popover.

Also added a few tests to make sure we don't regress on this again.

This popped up again because we were checking the panelId to make sure that we are in the correct Popover.Panel. However, the panelId is set when the Popover.Panel is rendered and it is registered in a useEffect. This is all fine-ish, however this causes a "delay" in the value being ready.

Combine this with wrapping the Panel inside a Transition component and the delay causes even more issues.

To fix this, we reset the PopoverPanelContext with a null value. That way the Popover itself will always reset it. This means that the moment we are in a panel, that we are always in the nearest panel. If the Popover components are nested, the nested Popover would reset the value of the parent Popover.Panel.

@vercel
Copy link

vercel bot commented Mar 3, 2023

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

Name Status Preview Comments Updated
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 3, 2023 at 1:53PM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 3, 2023 at 1:53PM (UTC)

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.

1 participant