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

Move scrolling to proper callback, avoid animation #4895

Merged

Conversation

josh-heyer
Copy link
Contributor

What Changed?

Appears there were at least three different places where scrolling would potentially be forced on navigation:

  1. a script injected by the autolink headers plugin (only on page load)
  2. gatsby's router logic (page load and internal navigation)
  3. navigation callback in gatsby-browser.js (page load and internal navigation)

...not to mention the default browser behavior, which would (should?) also work on page load.

Generally, this didn't seem to cause issues, but occasionally an odd behavior would emerge: navigating to a section within a page would jump the scroll position much further down. Oddly, this seems to disappear if the #3 logic is eliminated in favor of a selective override of #2.

@josh-heyer josh-heyer added the deploy Add this label to a PR and it will automatically be deployed to netlify label Oct 11, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 11, 2023

@github-actions github-actions bot temporarily deployed to pr-4895-bugfix-josh-squash-weird-scrolling-on-fragment-link October 11, 2023 05:40 Inactive
@djw-m
Copy link
Contributor

djw-m commented Oct 11, 2023

Seems to work here, much snappier browsing the reference too.

@github-actions github-actions bot temporarily deployed to pr-4895-bugfix-josh-squash-weird-scrolling-on-fragment-link October 11, 2023 19:19 Inactive
@josh-heyer josh-heyer force-pushed the bugfix/josh/squash-weird-scrolling-on-fragment-link branch from f5e0f27 to f93fc46 Compare October 12, 2023 03:09
@josh-heyer josh-heyer merged commit 0311a9c into develop Oct 12, 2023
1 check passed
@josh-heyer josh-heyer deleted the bugfix/josh/squash-weird-scrolling-on-fragment-link branch October 12, 2023 03:09
@josh-heyer josh-heyer mentioned this pull request Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy Add this label to a PR and it will automatically be deployed to netlify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants