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

Remove forceRerender from Tab component #1846

Merged
merged 2 commits into from
Sep 12, 2022
Merged

Conversation

RobinMalfait
Copy link
Member

This was necessary to ensure the Panel and the Tab were properly
connected with eachother because it could happen that the Tab renders
but the corresponding Panel is not the active one which means that it
didn't have a DOM node and no id attached.

Whenever new Tab became active, it rerendered but the Panel wasn't
available yet, after that the Panel rendered and an id was available
but the actual Tab was already rendered so there was no link between
them.

We then forced a re-render because now the Panel does have a DOM node
ref attached and the aria-labelledby could be filled in.

However, in #1837 we fixed an issue where the order of Tab elements
with their corresponding Panel elements weren't always correct. To fix
this we ensured that the Panel always rendered a <Hidden />
component which means that a DOM node is always available.

This now means that we can get rid of the forceRerender.

This was necessary to ensure the `Panel` and the `Tab` were properly
connected with eachother because it could happen that the `Tab` renders
but the corresponding `Panel` is not the active one which means that it
didn't have a DOM node and no `id` attached.

Whenever new `Tab` became active, it rerendered but the `Panel` wasn't
available yet, after that the `Panel` rendered and an `id` was available
but the actual `Tab` was already rendered so there was no link between
them.

We then forced a re-render because now the `Panel` does have a DOM node
ref attached and the `aria-labelledby` could be filled in.

However, in #1837 we fixed an issue where the order of `Tab` elements
with their corresponding `Panel` elements weren't always correct. To fix
this we ensured that the `Panel` always rendered a `<Hidden />`
component which means that a DOM node is always available.

This now means that we can get rid of the `forceRerender`.
@vercel
Copy link

vercel bot commented Sep 12, 2022

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

Name Status Preview Updated
headlessui-react ✅ Ready (Inspect) Visit Preview Sep 12, 2022 at 11:50AM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview Sep 12, 2022 at 11:50AM (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