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

[Bug]: Accordion / Collapsible components default open on SSR #978

Closed
benjamincanac opened this issue May 29, 2024 · 10 comments
Closed

[Bug]: Accordion / Collapsible components default open on SSR #978

benjamincanac opened this issue May 29, 2024 · 10 comments
Labels
bug Something isn't working v2

Comments

@benjamincanac
Copy link
Contributor

Environment

Developement/Production OS: Mac OS
Node version: 20.3.1
Package manager: pnpm@9
Radix Vue version: 1.8.2
Nuxt version: 3.11.2
Nuxt mode: universal
Nuxt target: server
CSS framework: tailwindcss@3.3.3
Client OS: Windows 10 19043.1110
Browser: Chrome 90.0.4430.212

Link to minimal reproduction

https://www.radix-vue.com/components/accordion

Steps to reproduce

Reload the documentation to see the menu open on client only.

Describe the bug

When using an Accordion with a default-value or a Collapsible with a default-open prop, the content will only be opened on client and blink when refreshing the page.

Expected behavior

No response

Context & Screenshots (if applicable)

No response

@benjamincanac benjamincanac added the bug Something isn't working label May 29, 2024
@zernonia zernonia added this to v2 May 29, 2024
@zernonia zernonia moved this to Backlog in v2 May 29, 2024
@zernonia zernonia added the v2 label May 29, 2024
@Cry0nicS
Copy link

Maybe relevant, as I didn't want to open another issue:

Same Accordion / Collapsible throws Hydration attribute mismatch when used with Nuxt and SSR (inclusive on the docs, linked in the initial post).

Hydration attribute mismatch on <div ... id=​"radix-vue-collapsible-content-57">​…​</div>​
  - rendered on server: id="radix-vue-collapsible-content-57"
  - expected on client: id="radix-vue-collapsible-content-8"

I'd assume useId() is required.

@zernonia
Copy link
Member

Thanks @teleskop150750 .. however I don't think that fixes the issue.

@Cry0nicS it's not hydration issue. If you encountered hydration issue do check out #577

@teleskop150750
Copy link
Contributor

Thanks @teleskop150750 .. however I don't think that fixes the issue.

@Cry0nicS it's not hydration issue. If you encountered hydration issue do check out #577

as far as I understand, the problem is in this code. First, the component is rendered with empty content. Then the parent component receives a link to "Presence". And only after that, if "present === true" the internal content is rendered

Link

@teleskop150750
Copy link
Contributor

I get the initial value synchronously

Parent
usePresence

@teleskop150750
Copy link
Contributor

Nuxt playground

@zernonia
Copy link
Member

zernonia commented Jul 2, 2024

Thanks @teleskop150750 . You are right with the condition to render the content, however the animation still would stutter in SSR. You can try to load the Animated Accordion in your Nuxt playground at the top of the page, and observe 😁

@teleskop150750
Copy link
Contributor

teleskop150750 commented Jul 2, 2024

@zernonia A temporary solution Link

@zernonia zernonia moved this from In progress to In review in v2 Jul 30, 2024
@teleskop150750 teleskop150750 mentioned this issue Sep 13, 2024
@zernonia
Copy link
Member

zernonia commented Nov 8, 2024

Fixed in reka-ui@latest 😁
Can be observed in https://reka-ui.com/docs/components/accordion

@almarzn
Copy link

almarzn commented Jan 19, 2025

Hello, this is marked as completed, but I am still getting this issue with radix-vue@1.9.12

Could you fix this for 1.9 pls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2
Projects
Status: Done
Development

No branches or pull requests

5 participants