- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Repeated click on anchor link fails to jump to target when navigation.instant
is enabled
#5954
Comments
Fixed in 7e6f15b. Sorry it took so long, but this was quite tricky! Took me 3 attempts. ProblemThe problem is that clicks on anchor links emit on SolutionWe create a second observable chain that intercepts emissions on This commit fixes another problem where tracking of scroll offset was not recorded before the first navigation. We track the offset and store it in the latest history state entry, so that when you go back, you land at exactly the same scroll position, even though you might go to an anchor link. This logic was only mounted after the first instant load, so if you clicked anchor links before navigating, the position was not recorded. My testing shows that the problem is solved. Can you confirm? |
@squidfunk Just saw this fix in |
It's really awesome to read that my work is being used in universities. When I was a student myself, I would've loved to learn about a technology like this in class. Kudos for using my work for teaching 🚀 |
Released as part of 9.4.2. |
Sorry for my delayed response, @squidfunk.
No worries, I had no expectations on timeline. It didn't feel like an obvious problem, so I appreciate your efforts in finding a proper fix! 🙏 Also, thank you very much for the detailed analysis and solution report! It indeed looks like a tricky problem to solve.
I confirm it's working now! Thank you very much! 🙇 |
Context
No response
Bug description
When the
navigation.instant
feature is enabled, clicking on an anchor link (e.g. a ToC link), then scrolling elsewhere, and then clicking on the same anchor link again does not work; the second click on the same anchor link does not jump to its target anymore. Clicking on another anchor link works fine though. The problem does not occur whennavigation.instant
is disabled.Related links
Reproduction
9.2.7-xhr-anchor-links.zip
Steps to reproduce
Browser
No response
Before submitting
The text was updated successfully, but these errors were encountered: