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

Improve SSR of the Disclosure component #2645

Merged
merged 4 commits into from
Aug 3, 2023
Merged

Improve SSR of the Disclosure component #2645

merged 4 commits into from
Aug 3, 2023

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Aug 3, 2023

This PR improves the SSR of the Disclosure component in a Vue js application.

When you don't pass in a custom ID, a fresh ID would be generated as the default logic for the id prop. However, this doesn't play nicely with Vue / Nuxt SSR. Restructuring the code and updating the ID on the client if an ID is passed solves the SSR issue.

We also added SSR related tests to show that SSR and Hydrating is working as expected.


This is still a WIP, because in Nuxt.js there is something happening that's a bit odd. The ID for the button and the panel are correct, and the aria-controls on the button points to the ID of the panel which is all fine.

The moment it is hydrated and you look at the devtools then the IDs do not line up anymore and they are different.

To make things worse, logging the ID that we are setting internally is showing the correct ID...
Going to pick @thecrypticace's brain for a bit to see if we can solve this or if this is a Nuxt.js bug.

This PR is already better than before, but hopefully we can solve that part as well.

Fixes: #2624

@vercel
Copy link

vercel bot commented Aug 3, 2023

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 Aug 3, 2023 2:27pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2023 2:27pm

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.

SSR Accessibility issues with Disclosure component on Nuxt3/Vue
1 participant