-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Labels
help wantedIssue with a clear description that the community can help with.Issue with a clear description that the community can help with.stale?Issue that may be closed soon due to the original author not responding any more.Issue that may be closed soon due to the original author not responding any more.type: bugAn issue or pull request relating to a bug in GatsbyAn issue or pull request relating to a bug in Gatsby
Description
Description
Clicking on a <Link> in v2 (111) appears to scroll you to a previous scroll position (if it exists) rather than scroll you to the top.
Steps to reproduce
I've been able to recreate this in gatsby-starter-default:
https://gatsby-v2-beta-111-scroll.netlify.com/
(The only change is artificial padding added to the first page above the /page-2 <Link>)
- Visit https://gatsby-v2-beta-111-scroll.netlify.com/
- On the home page, scroll down to the
page-2link and click it - On
page-2, now click 'Go back to the homepage'
Expected result
You are taken back to the top of the home page
Actual result
You are taken back to the home page but scrolled down the page (at the exact same position you were when you linked the page-2 link)
Environment
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.1 - ~/.nvm/versions/node/v8.11.1/bin/node
Yarn: 1.9.4 - ~/.nvm/versions/node/v8.11.1/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.11.1/bin/npm
Browsers:
Chrome: 68.0.3440.106
Firefox: 61.0.1
Safari: 11.1.2
npmPackages:
gatsby: next => 2.0.0-beta.111
gatsby-plugin-manifest: next => 2.0.2-beta.6
gatsby-plugin-offline: next => 2.0.0-beta.9
gatsby-plugin-react-helmet: next => 3.0.0-beta.4
npmGlobalPackages:
gatsby-cli: 1.1.58
Other notes
- This behaviour doesn't occur on the v1 starter.
- I understand that there was a switch to
reach-router, could this be linked? - Manually adding
window.scrollTo(0, 0) / window.scroll({top: 0})in pagecomponentDidMounthad no effect, though it would work after wrapping it in an arbitrarysetTimeout- though this yields an initial flash of content in the wrong scroll position.
By default, I imagine the desired behaviour would be for all clicked <Link> elements to scroll you to the top of that target page and that only using the browser back / forward buttons would retain scroll position state in this manner.
jayalfredprufrock, humphreybc, monsieurnebo, dannywils, ryanwiemer and 13 more
Metadata
Metadata
Assignees
Labels
help wantedIssue with a clear description that the community can help with.Issue with a clear description that the community can help with.stale?Issue that may be closed soon due to the original author not responding any more.Issue that may be closed soon due to the original author not responding any more.type: bugAn issue or pull request relating to a bug in GatsbyAn issue or pull request relating to a bug in Gatsby