-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
bug: navigating to anchor links within an admonition not working with navigation.instant #5239
Comments
Thanks for reporting, and especially for the excellent reproduction. That made troubleshooting straightforward. This is a regression of the latest refactoring in instant loading and I took the time to investigate why this is the case. My findings: Previously, instant loading filtered hash changes (= clicking on anchors) that happen on the same page, and leave them to the browser. This triggered the logic we have in place to detect whether an anchor is targeting something that is located in a hidden element, which is currently only implemented for mkdocs-material/src/assets/javascripts/components/content/details/index.ts Lines 86 to 94 in ab23604
Now, if you look at the commit history, these lines were added two years ago before the advent of code annotations, content tabs with anchor links and other features that may include anchors in hidden elements. The latest refactoring of instant loading that was released in 9.1.1 has a different behavior as it will now also handle anchor links. The reason is primarily to correctly implement scroll restoration, i.e., when you click on a link, then scroll down, then navigate away and go back to that section. Additionally, instant loading had sometimes problems on slow connections, which were also fixed with this release. However, it leads to the problem that in some browsers (notably Firefox and Safari), the mkdocs-material/src/assets/javascripts/integrations/instant/index.ts Lines 141 to 146 in ab23604
The issue should be fixed with 183b0be. I consider this a temporary bandaid, as we must defer control of anchor links to instant loading for the reasons stated. We will soon tackle proper expansion of nested hidden elements, which is not solely relevant when following anchor links, but also for search highlighting (see #4125). Also, see #4125 (comment) why this is particularly challenging, as cases become pathological quite quickly. |
Released as part of 9.1.4. |
Sorry for commenting on a closed thread but (If that's not a known issue, I can prepare a repro scenario soon!) navigation-instant-bug.mp4 |
Not known. Please create a bug report, provide a minimal reproduction, and we're happy to look into it! |
- Adds cheating callout in team exercises section - Reinforce individual work of homework assignments - Disable `navigation.instant` due to anchor link issues with Safari: squidfunk/mkdocs-material#5239 (comment)
* Update time, location and schedule for F23 * Adds academic misconduct section - Adds cheating callout in team exercises section - Reinforce individual work of homework assignments - Disable `navigation.instant` due to anchor link issues with Safari: squidfunk/mkdocs-material#5239 (comment)
Context
We have a "reported issues" tracking page on our documentation that utilizes H3 elements within collapsed admonitions to help provide navigation on page with the TOC and create a more condensed page (reading wise).
Recently we reintroduced
navigation.instant
to our docs as part of mkdocs-material 9.1.1 to solve the following issues outlined in this PR:Ideally what usually happens is when a user clicks on a link in the TOC it would take them to the relevant section on the page and open the admontion.
removed live site example as we removed instant navigation on production
example.zip with minimal repro provided below
Bug description
Issue
With
navigation.instant
enabled on our build we recently discovered that clicking on links in the table of contents in certain browsers outlined below would not jump to the relevant anchor/section when the header is positioned within a collapsible admonition.It is currently not working on:
Example:
Additional Context
This setup has worked for us on all browsers and devices until we discovered this issue recently with no changes to our build. Currently, it only works on the Chrome Browser (Windows + MacOS + Mobile Devices).
It is important to note that anchor links / section links work flawlessly on any browser when the header is not placed within an admonition.
Related links
Relevant Discussions I looked at:
Reproduction
Example provided below
Please see the page titled
Example Issue:
it is a clone of our reported issues page on our live site.example.zip
Steps to reproduce
navigation.instant
is active in the config.mkdocs serve
or buildlocalhost:8000
or open index.html on Safari or FirefoxExpected outcome: You would be taken to the link you clicked on in the TOC + admonition would open to reveal content.
Current outcome: Navigation does not happen and TOC links are inoperable.
Example admonition setup:
Browser
Safari, Firefox
Before submitting
The text was updated successfully, but these errors were encountered: