-
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
gatsby-remark-autolink-headers doesn't apply offset when clicking on hash link within same page #7590
Comments
Thanks for sending this in @alexandernanberg 👍 |
Hey @alexandernanberg what's mostly wrong here is that |
@pieh just so we're clear here, you're suggesting that we shouldn't rely on onRouteUpdate to be called (with a hash change), and should instead solve the hash navigation problem differently (i.e. with a custom script or something) in this plugin? |
Wouldn't the best way be to use the |
Meaning use that instead of the a tag? I don't think that's possible, but we probably can use something from react/router to enable this functionality a little more cleanly. |
I think we can hook into
|
No not really, the |
Description
If the history updates without the update originating from a
Link
componentonRouteUpdate
won't fire, eg.<a href="#some-id">Scroll to some id</a>
.This causes plugins like
gatsby-remark-autolink-headers
to not work like you would expect when having inline links in the markdown. Try using the links in the TOC and you'll notice that they don't align correctly with the viewport.https://deploy-preview-1104--reactjs.netlify.com/docs/getting-started.html
Same thing happens on https://next.gatsbyjs.org/docs/migrating-from-v1-to-v2/
Steps to reproduce
<a href="#some-id">Scroll to some id</a>
+ and element with the id.onRouteUpdate
function.Notice that it won't fire when clicking the anchor tag.
Expected result
onRouteUpdate
should be called.Actual result
onRouteUpdate
isn't called.Environment
File contents (if changed)
gatsby-config.js
: N/Apackage.json
: N/Agatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/AThe text was updated successfully, but these errors were encountered: