Gatsby: Gatsby websites auto scroll back to the top

Created on 11 Jul 2018  Β·  11Comments  Β·  Source: gatsbyjs/gatsby

Description

When a Gatsby website loads, the user can happily start scrolling. However, after some time has elapsed the page scrolls back up to the top.

Steps to reproduce

This can be reproduced at https://www.gatsbyjs.org/ or https://reactjs.org/ by going to the website with a throttled network connection and scrolling down before render() is called.

Expected result

It should not scroll to the top

Actual result

It scrolls to the top. This will not happen if JS is disabled.

Environment

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

help wanted stale? bug

Most helpful comment

@wardpeet actually fixed this a couple of weeks ago!

https://github.com/gatsbyjs/gatsby/pull/11224

All 11 comments

Thanks for the report @DeveloperDavo. This is mentioned over in #5675. For anyone interested in picking this up, check the discussion in 5675 for pointers on where to start investigating.

Any update on this? I don't believe it's resolved in v2.

@humphreybc no not yet unfortunately. The fix is I believe to check in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-react-router-scroll/README.md if scroll has already happened and to _not_ then scroll to the top which is it's default. Or perhaps easier to just not scroll at all on the initial load of the website.

Would you like to work on a PR? This would be really nice to fix!

@KyleAMathews I would love to but I'm a bit short on time right now unfortunately πŸ™

No worries :-) hopefully someone will pick this up soon

I think this would be fixed by returning false in shouldUpdateScroll. The problem is: what should happen on page reload (when we want to scroll to the last saved position)?

This is probably the same thing that is happening for me whenever I am actively scrolling the page and a part of the DOM changes with a timer. I'll try to post a simple repro.

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

I really think that this one is important

@wardpeet actually fixed this a couple of weeks ago!

https://github.com/gatsbyjs/gatsby/pull/11224

Very good

Thank you very much

On Sun, 3 Feb 2019, 04:04 Kyle Mathews <[email protected] wrote:

@wardpeet https://github.com/wardpeet actually fixed this a couple of
weeks ago!

11224 https://github.com/gatsbyjs/gatsby/pull/11224

β€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/6392#issuecomment-460021230,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AH_TYa40H88TvTPGJoR163--0dn3TjR0ks5vJl-wgaJpZM4VLn7B
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andykais picture andykais  Β·  3Comments

ghost picture ghost  Β·  3Comments

dustinhorton picture dustinhorton  Β·  3Comments

timbrandin picture timbrandin  Β·  3Comments

hobochild picture hobochild  Β·  3Comments