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

Template Ref clientHeight 0 after page change #13270

Closed
chrispreisler opened this issue Jan 19, 2022 · 3 comments
Closed

Template Ref clientHeight 0 after page change #13270

chrispreisler opened this issue Jan 19, 2022 · 3 comments

Comments

@chrispreisler
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0-27369360.33ebb01
  • Package Manager: yarn@1.22.17
  • Bundler: Vite
  • User Config: publicRuntimeConfig, buildModules, build, hooks, noopTransform
  • Runtime Modules: -
  • Build Modules: @vueuse/nuxt@7.5.3

Reproduction

https://stackblitz.com/edit/nuxt3-windicss-t6zmdt?file=pages%2Findex.vue

Describe the bug

I created a reproduction link to show the bug. When loading the page, it gives me the height of the blue container. When navigating to About and back to home, clientHeight suddenly is 0. In my opinion this should work and also worked in nuxt2. Also I created a reproduction with vue3 to check, if it is a vue3 bug. But in vue3 it is working without problems:

https://stackblitz.com/edit/vue3-vue-router-demo-jrbsbi?file=src%2Fviews%2FHome.vue

Thanks guys for your help.

Additional context

No response

Logs

No response

@chrispreisler
Copy link
Author

This is fixed by adding a key to

<NuxtPage :key="$route.fullPath" />

@danielrjames
Copy link

danielrjames commented Apr 30, 2022

This is fixed by adding a key to

<NuxtPage :key="$route.fullPath" />

@chrispreisler How did you come to this solution? It solved a similar issue I was having (template ref would not focus in onMounted).

@ninghao
Copy link

ninghao commented Jul 4, 2022

This is fixed by adding a key to

<NuxtPage :key="$route.fullPath" />

took me two days to find this line of code.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants