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

Not scrolling to top on navigation (Firefox, scroll-behavior: smooth) #28227

Open
JovanaMatic opened this issue Jul 19, 2024 · 2 comments
Open

Comments

@JovanaMatic
Copy link

Environment

Nuxt 3

Reproduction

Repository: https://github.com/JovanaMatic/nuxt-scroll-issue.git

package.json:

{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "nuxt": "^3.12.4",
    "vue": "latest"
  }
}

nuxt.config.js

export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  css: [
    '~/assets/global.css'
  ]
})

Describe the bug

Reporting the same issue in Nuxt 3.

In our project we have footer element with various NuxtLinks that lead to different pages when clicking on them. When navigating through the links inside footer we experience the scrolling issue. This issue is more visible on Firefox however it is also reproducible on Chrome and Safari browser. When navigating through routes Firefox is forcefully scrolling to the bottom of the page instead of the top of the page.
We noticed that when removing scroll-behavior: smooth; property from html global class, this behaviour will slightly disappear however it can still be reproduced, user can still, by clicking on links after some time, be scrolled to the bottom of the page which is not expected. When navigating to new page, user should be scrolled to the bottom of that page.

Browser versions:
Chrome: 126.0.6478.127
Firefox: Version 127.0.2
Safari: 17.5

Node version: v20.12.2
Nuxt version: 3.12.4

Additional context

Steps to reproduce:

  1. open the index page (eg. http://localhost:3000/) in Firefox

  2. scroll to the bottom of the index page

  3. click the navigation button (pointing to for example lease-end or loan-end)

  4. on the new route, the page does not scroll to the top as expected

Logs

No response

@huang-julien
Copy link
Member

Hello I can't reproduce the issue on firefox 128.0

@JovanaMatic
Copy link
Author

Just updated to Firefox version 128.0 and I can reproduce the issue.

Steps to reproduce:

  1. start dev server
  2. open index page on Firefox
  3. scroll to the bottom of the page
  4. click on "Contact us" route - new /contact-us page will be opened and user is scrolled to the top of the page which is expected
  5. go back to the index page and click on "New customer" link - user will be navigated to /welcome page however page will be stuck on the bottom, there is no scrolling to the top which is not expected
    User should be scrolled to the top of the page.

Additional note: by going through navigation through router links in footer it seems that this issue is intermittent however it can be reproduced by going to index page directly and clicking on "New customer for example" or by following the steps above.

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

2 participants