-
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
fix(gatsby-react-router-scroll): Respect hash as source of truth for scroll position #28555
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so much better than before! 💯 Let's see if we can fix the reach bug in the future, but this is a massive improvement over users having to double click on links to navigate to anchors.
Ooo nice! I'd noticed this too. |
@KyleAMathews Yeah, it was annoying one. @mxstbr and I paired on this earlier today. |
@sidharthachatterjee Thanks for this fix, very much appreciated! Was wondering about this:
Is there an issue/PR where we can track this work? Thanks! |
Has a fix been merged in? I am using gatsby-react-router-scroll 3.7 and still seeing the issue |
Using gatsby-react-router-scroll the current implementation :
in the other div : |
I can also confirm that this is not working using |
Co-authored-by: Mitchell Bennett <[email protected]> Fixes #28555
Currently we do not navigate correctly to hashes unless the scroll position is zero. If you're scrolled to any position other than the top, you will need to click twice to scroll to the correct position. This behaviour is completely broken at the moment.
This PR fixes this (albeit not completely) by always respecting the hash and scrolling to it irrespective of if there is browser scrolling state or not. This is iteratively better than our current behaviour. However, the ideal behaviour (which we ought to handle in a separate PR) is to respect hash except when navigating back in the browser (in which case, we ought to restore scroll position). Reach currently has this bug which we can track at reach/router#228
Closes #25778