unovue / radix-vue

Vue port of Radix UI Primitives. An open-source UI component library for building high-quality, accessible design systems and web apps.
https://radix-vue.com
MIT License
3.54k stars 217 forks source link

[Bug]: Hydration attribute mismatch #1282

Closed HaraldHenriksson closed 1 month ago

HaraldHenriksson commented 1 month ago

Environment

Developement/Production OS: MacOS 14.6.1
Node version: 20.11.1
Package manager: npm@10.2.4
Radix Vue version: 1.9.5
Vue version: 3.5.3
Nuxt version: 3.0.0
Nuxt mode: universal
Nuxt target: server
@nuxtjs/tailwindcss": 6.12.1
Client OS: MacOS 14.6.1
Browser: Chrome 128.0.6613.113

Link to minimal reproduction

https://codesandbox.io/p/devbox/amazing-merkle-v27268?layout=%257B%2522sidebarPanel%2522%253A%2522GIT%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522cm0wc4x7c00073b6i419qbrdg%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522cm0wc4x7b00023b6ifti7h3qu%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522cm0wc4x7c00043b6i124sxr3p%2522%257D%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522cm0wc4x7c00063b6iobbw6spr%2522%257D%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522cm0wc4x7b00023b6ifti7h3qu%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cm0wc4x7b00013b6i98jkwjkg%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522cm0wca0fl00023b6ipwmxl506%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A18%252C%2522startColumn%2522%253A1%252C%2522endLineNumber%2522%253A18%252C%2522endColumn%2522%253A1%257D%255D%252C%2522filepath%2522%253A%2522%252Fpackage.json%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522cm0wc4x7b00023b6ifti7h3qu%2522%252C%2522activeTabId%2522%253A%2522cm0wca0fl00023b6ipwmxl506%2522%257D%252C%2522cm0wc4x7c00063b6iobbw6spr%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cm0wc4x7c00053b6izfxh7uaf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A3000%257D%255D%252C%2522id%2522%253A%2522cm0wc4x7c00063b6iobbw6spr%2522%252C%2522activeTabId%2522%253A%2522cm0wc4x7c00053b6izfxh7uaf%2522%257D%252C%2522cm0wc4x7c00043b6i124sxr3p%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cm0wc4x7c00033b6i48sobnjz%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%255D%252C%2522id%2522%253A%2522cm0wc4x7c00043b6i124sxr3p%2522%252C%2522activeTabId%2522%253A%2522cm0wc4x7c00033b6i48sobnjz%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

Steps to reproduce

Create a Nuxt.js project with server-side rendering.

Install radix-vue

Add Accordation component:

Run application with SSR(default)

Observe the issue

Describe the bug

The ID's generated during server-side rendering differ from those generated on the client during hydration.

Expected behavior

The server and client IDs should match to prevent hydration mismatches during SSR.

Context & Screenshots (if applicable)

Screenshot 2024-09-10 at 13 40 51

zernonia commented 1 month ago

Duplicated of https://github.com/radix-vue/radix-vue/issues/577, please find the solution in the issue

HaraldHenriksson commented 1 month ago

@zernonia useId should not be needed in vue 3.5 if im correct? thanks for your reply

zernonia commented 1 month ago

Technically yes. But internally we are still using interal useId, and requires user to pass in useId function still. Here's a ticket for using newly introduced useId from Vue https://github.com/radix-vue/radix-vue/issues/1267