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

Incorrect scroll top position when navigating between pages #25745

Closed
josephmarkus opened this issue Jul 14, 2020 · 0 comments · Fixed by #25749
Closed

Incorrect scroll top position when navigating between pages #25745

josephmarkus opened this issue Jul 14, 2020 · 0 comments · Fixed by #25749
Assignees
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) type: bug An issue or pull request relating to a bug in Gatsby

Comments

@josephmarkus
Copy link
Contributor

Description

After upgrading from gatsby@2.20.26 to gatsby@2.24.2 I noticed an issue where navigating within the app sets incorrect scroll top position.

NOTE: I previously raised this here - #25554 and suggested fix through

"resolutions": {
  "gatsby-react-router-scroll": "3.0.3"
}

Didn't fix it for me.

And as @blainekasten suggested, I'm creating a new issue as it's different to that raised by the author of #25554

Steps to reproduce

  1. Make sure you have latest version of gatsby installed - gatsby@2.24.2
  2. Run gatsby develop
  3. Click on a link that isn't at the very top of the page (e.g. your site's footer). You can check this in your DevTools console by logging out window.scrollY. As long as it's more than 0 then you're good.
  4. Once you navigate to a new page observe that your scrollTop position is not 0 (again, can verify as detailed in the previous step)

Expected result

After navigating to a new page user should be scrolled to the top of the page. In other words, window.scrollY should return 0 after navigating to a new page.

Actual result

If page that user navigated from had a window.scrollY value of 1500, the new page will also return 1500 when logging out window.scrollY

Environment

System:
    OS: macOS Mojave 10.14.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.18.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 83.0.4103.116
    Safari: 13.1.1
  npmPackages:
    gatsby: ~2.24.2 => 2.24.2
    gatsby-background-image: ^1.1.1 => 1.1.1
    gatsby-image: ~2.4.12 => 2.4.12
    gatsby-plugin-catch-links: ~2.3.10 => 2.3.10
    gatsby-plugin-emotion: ~2.0.5 => 2.0.7
    gatsby-plugin-favicon: ~3.1.5 => 3.1.6
    gatsby-plugin-google-gtag: ~2.1.9 => 2.1.9
    gatsby-plugin-manifest: ~2.4.17 => 2.4.17
    gatsby-plugin-mdx: ^1.2.22 => 1.2.22
    gatsby-plugin-postcss: ~2.3.9 => 2.3.9
    gatsby-plugin-react-helmet: ~3.3.9 => 3.3.9
    gatsby-plugin-remove-generator: ^1.0.5 => 1.0.5
    gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0
    gatsby-plugin-robots-txt: ~1.5.1 => 1.5.1
    gatsby-plugin-root-import: ~2.0.5 => 2.0.5
    gatsby-plugin-sharp: ~2.6.18 => 2.6.18
    gatsby-plugin-sitemap: ~2.4.10 => 2.4.10
    gatsby-remark-autolink-headers: ^2.3.10 => 2.3.10
    gatsby-remark-copy-linked-files: ^2.3.10 => 2.3.10
    gatsby-remark-external-links: ~0.0.4 => 0.0.4
    gatsby-remark-images: ~3.3.17 => 3.3.17
    gatsby-remark-relative-images: ^0.2.2 => 0.2.3
    gatsby-remark-responsive-iframe: ~2.4.10 => 2.4.10
    gatsby-source-filesystem: ~2.3.18 => 2.3.18
    gatsby-source-youtube-v2: ^1.0.1 => 1.0.1
    gatsby-transformer-remark: ^2.8.23 => 2.8.23
    gatsby-transformer-sharp: ~2.5.10 => 2.5.10
  npmGlobalPackages:
    gatsby-cli: 2.12.59
@josephmarkus josephmarkus added the type: bug An issue or pull request relating to a bug in Gatsby label Jul 14, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 14, 2020
@sidharthachatterjee sidharthachatterjee added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jul 14, 2020
@blainekasten blainekasten self-assigned this Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants