-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Scroll to top on page refresh #10422
Comments
This was fixed in #8359 Can you link to a minimal reproduction for this? |
Hello @sidharthachatterjee ,
|
Hey @ashleybeshir What you're seeing is intended scroll behaviour. Gatsby maintains the scroll position of a page and restores it after refresh. The A cleaner and more reliable way to manage scroll behaviour is by using the shouldUpdateScroll browser API. |
@sidharthachatterjee Thank you will have a look at them now |
@ashleybeshir You're welcome 🙂 I'm closing this in the mean time but please feel free to reopen this if there is anything else. |
Summary
When the page refreshes i want it to scroll to top of the page. I added window.scrollTo(0, 0); into both componentDidUpdate and componentDidMount. So it should be doing it ? but when page refreshes it still stays at the same Y scroll position
Relevant information
Their are few other tickets for this issue in gatsby 1 but not sure if it been fixed in gatsby 2
Environment (if relevant)
System:
OS: Windows 10
CPU: (8) x64 AMD FX(tm)-8350 Eight-Core Processor
Binaries:
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1.0
npmPackages:
gatsby: ^2.0.19 => 2.0.19
gatsby-image: ^2.0.15 => 2.0.15
gatsby-plugin-emotion: ^2.0.6 => 2.0.6
gatsby-plugin-manifest: ^2.0.5 => 2.0.5
gatsby-plugin-no-sourcemaps: ^2.0.1 => 2.0.1
gatsby-plugin-offline: ^2.0.5 => 2.0.5
gatsby-plugin-react-helmet: ^3.0.0 => 3.0.0
gatsby-plugin-sharp: ^2.0.7 => 2.0.7
gatsby-source-filesystem: ^2.0.4 => 2.0.4
gatsby-transformer-sharp: ^2.1.4 => 2.1.4
The text was updated successfully, but these errors were encountered: