Skip to content

NuxtLink with anchor (hash) doesn't jump to element unless defined as external #32366

@MasterCarl

Description

@MasterCarl

Environment

  • Operating System: Linux
  • Node Version: v20.19.1
  • Nuxt Version: 3.17.5
  • CLI Version: 3.25.1
  • Nitro Version: 2.11.12
  • Package Manager: npm@10.8.2
  • Builder: -
  • User Config: compatibilityDate, devtools
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-d1n2dope?file=pages%2Findex.vue

Click a NuxtLink that links to a specific element on another page, like /example#two. The section is only scrolled into view when reloading the page.

Describe the bug

When using a link to a specific element, that element is not scrolled into view.
Adding external works, but seems to trigger server-side rendering.

Additional context

I'm not sure when the problem appeared, but navigating straight to a specific section used to work.
Our end-to-end tests failed after upgrading from 3.16.0 to 3.17.5, though I could reproduce the error on 3.16.0 in StackBlitz.

Logs

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions