-
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
Anchor links don't work #25554
Comments
Thanks for the detailed issue, reproduction and video! Really appreciate it 👍 I was able to reproduce this locally but reproduction is not reliable. One time it works, the other time it doesn't. Also, sometimes it starts working after scrolling the page up and down. It looks like At least I can't reproduce this problem on versions prior to it. Can you also try reproducing it with I've used yarn resolutions to test it. Add this to "resolutions": {
"gatsby-react-router-scroll": "3.0.3"
} |
@vladar yes, this issue is random and I decided to create a recording so you can believe me :) I tried |
Myself and someone else I know were having this issue but it's now resolved with the resolutions.
Where should I be watching for this to be fixed @vladar? I don't actually use Is it fair presume this is now fixed with #25161 ? |
same issue here! |
@dalxds try to use |
@AndrejGajdos I'll try it and I'll let you know. thanks! |
@AndrejGajdos which version did you have in mind? |
@josephmarkus sorry, it was |
@AndrejGajdos I've just tried 2.24.2, but it's the same issue. I cannot see anything in the changelog that would say that this issue has been addressed. Is there an ETA for when this would be fixed? |
I'm going to close this issue as the original reporter's issue has been solved! Feel free to keep discussing here or opening a new issue. For those still experiencing the issue, it seems like you might have some dependency issues. Try deleting your node_modules, clearing cache and re-installing fresh! |
I don't think it should be closed. This workaround with yarn resolutions should be added to Readme or documentation. |
I tried
and the problem still persists |
I raised a new issue which I think is this same issue but I'm not sure, anyway it's #25778 if anyone's interested. |
have same problem, I am not sure when it started, I didn't have this problem before, so my guess is that it happened after some package update, as for gatsby version, I now have "gatsby": "^2.24.7"... I just tried to run npm update and updated all packages to latest and guess what, the problem still exists + I got other issues that broke my app logic in some parts :) so had to downgrade and will just use my own workaround to handle anchor links clicks in table of contents |
I have the same problem with "gatsby": "2.24.73", I tried the resolution but is not working "resolutions": { |
There is super easy solution to this problem. Use Gatsby Link component for anchor links, don't use a for that. Gatsby documentation specifically says that we must use a for anchor links, but it simply fails when it's about smooth scrolling. I replaced a with Link and everything magically works after that. I also added scroll-behavior: smooth; for html in styles |
@brootle you are right, my problem was gatsby-link, I just replaced for an anchor tag and the issue was solved, Thanks, I did not see the documentation recommendations |
I didn't notice that |
oh dude, what a happy misunderstanding! in my case |
@rootlinux2 Thanks for sharing the documentation link, updating Gatsby to the latest version and using |
Using Gatsby Link takes advantage of faster page navigation. Using anchor tags will cause a full page refresh. |
@josephmarkus what could I do? in the gatsby documentation, they recommend to use tag for anchor links my first instinct was to use the gatsby link but I face this issue. Do you have a better idea? |
The idea is to use Gatsby Link for any links within your application (e.g. a link on homepage to about page). For everything else, you should use anchor tag ( This is what I have in my
|
I think I got confused. <a href="#content">Link</a>
...
<div id="content"></div> |
You can also use #hash-links when coming from another page. For example |
Whaf is this "resolutions": { } thing? |
@danmorley here's some documentation on |
Description
I use
gatsby-transformer-remark
to parse markdown files and get table of contents. If I hit an item in table of contents (anchor link), the browser doesn't scroll to the section.Steps to reproduce
I created a basic demo project here. If you open for example http://localhost:8000/docs/tauchain-agoras-faqs and scroll to the bottom, you can see table of content there.
I created a recording, where I click on items in table of contents and nothing happens.
Expected result
If item in table of contents is clicked, browser should scroll to that section.
Actual result
The browser doesn't scroll to the section, it just changes hash in browser url address.
Environment
The text was updated successfully, but these errors were encountered: