-
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-remark-autolink-headers): use shouldUpdateScroll api and not onRouteUpdate #9657
Conversation
… on scroll handling
window.scrollTo(0, offset - offsetY) | ||
} | ||
const getTargetOffset = hash => { | ||
const id = window.decodeURI(window.location.hash.replace(`#`, ``)) |
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.
Might be missing something – but shouldn't this be hash
instead of window.location.hash
here?
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.
Seems reasonable! window.location.hash is already being passed here, so seems like you're right!
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.
Ah, thanks!
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.
Also @pieh you're probably aware, but it seems like that pathPrefix test has one flaky test that sometimes fails with:
Definitely unrelated to this PR, I'd think. |
…ot onRouteUpdate (gatsbyjs#9657) * use shouldUpdateScroll api to not battle with builtin scrollbehaviour on scroll handling * use passed hash, doh
right now autolink-headers scroll is battling with scrollbehaviour and which should handle scroll to
#elementId
. This allowautolink-headers
plugin to hook into scrollbehaviour to override default behaviour.Potential problems:
shouldUpdateScroll
is API that handles only one instance of this hook, so using it in autolink-headers plugin will discard results of this hook in user code (if it's used there)closes #9638