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

Hydration issues - Nuxt 3/Vue 3 #1006

Open
jawngee opened this issue Dec 31, 2023 · 11 comments
Open

Hydration issues - Nuxt 3/Vue 3 #1006

jawngee opened this issue Dec 31, 2023 · 11 comments

Comments

@jawngee
Copy link

jawngee commented Dec 31, 2023

This just started showing up in the latest Nuxt 3.9, probably due to the Vue version bump but I'm not sure.

Getting a lot of Hydration attribute mismatch because the ID of the popper is different from SSR. Errors look like:

- rendered on server: id=\"popper_44tr48ae_tdggwc\"
- expected on client: id=\"popper_gjw3s4ml_tdglzw\"
  Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.

Not sure how to solve this or if it has any real impact at all.

@simba77
Copy link

simba77 commented Jan 9, 2024

As a temporary solution, you can add the aria-id attribute
<v-dropdown aria-id="some-dropdown">

@Akryum
Copy link
Owner

Akryum commented Jan 11, 2024

Yes you can use ariaId prop to prevent using a random id for the aria-describedby attribute.
Maybe it could be fixed in nuxt via the module but I'm not sure.

@Akryum
Copy link
Owner

Akryum commented Jan 11, 2024

Also is this caused by popper that are already open when they are rendered on the server? For example with :shown="true"

@jawngee
Copy link
Author

jawngee commented Jan 11, 2024 via email

@sbittmann
Copy link

sbittmann commented Jan 16, 2024

in Nuxt3 I used

<ClientOnly>
    <template #fallback>
        <Item2Render />
    </template>
    <VTooltip>
        <Item2Render />
        <template #popper>
            <PopperContent />
        </template>
    </VTooltip>
<ClientOnly>

@yoshrubin
Copy link

the above works for the ariaId issue but I am getting

 - rendered on server: tabindex=""
  - expected on client: tabindex="0"
  Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
  You should fix the source of the mismatch. 
  at <VPopperContent ref="popperContent" popper-id="dropdown" theme="info-dropdown"  ... > 
  at <Popper ref="popper" theme="info-dropdown" referenceNode=null  ... > 
  at <Dropdown triggers= ['click'] skidding=-30 distance=25 > 

when using a Dropdown so the contents of the Popper are clickable

@Mini-ghost
Copy link

Yes you can use ariaId prop to prevent using a random id for the aria-describedby attribute. Maybe it could be fixed in nuxt via the module but I'm not sure.

This was useful for me, but it might not be the best approach as it causes the vuejs-accessibility's aria-props to throw errors at me. I wonder if there's another way to address this?

eslint-disable vuejs-accessibility/aria-props

@Dodje
Copy link

Dodje commented Feb 6, 2024

I believe it's not a very good thing to generate id for every tooltip and dropdown manually..

@Nuzzlet
Copy link

Nuzzlet commented Feb 19, 2024

Headless UI solved this problem with the new UseID function in Nuxt
This solution uses Nuxt's new UseID composable to generate an SSR safe ID.
The warning is caused by the latest version of Nuxt which improved hydration mismatch detection.

@Nuzzlet
Copy link

Nuzzlet commented Mar 19, 2024

My soloution for the time being is this:

<script setup>
    const ariaId = useId()
</script>

<template>
    <VDropdown :aria-id="ariaId"  />
</template>

connoratrug added a commit to molgenis/molgenis-emx2 that referenced this issue Mar 20, 2024
The VDropdown component from the floating-vue lib results in a hydration errors due to the way the lib edits the dom
issue is reported: Akryum/floating-vue#1006

Workaround implemented as proposed in: Akryum/floating-vue#1006 (comment)
connoratrug added a commit to molgenis/molgenis-emx2 that referenced this issue Mar 21, 2024
The VDropdown component from the floating-vue lib results in a hydration errors due to the way the lib edits the dom
issue is reported: Akryum/floating-vue#1006

Workaround implemented as proposed in: Akryum/floating-vue#1006 (comment)
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

No branches or pull requests

9 participants