Skip to content

bug: navigating to anchor links within an admonition not working with navigation.instant #5239

@Valastiri

Description

@Valastiri

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:

  • Safari (all devices)
  • Firefox (Windows + iPadOS tested)

Example:

??? bug "Title of Admonition"
		### header

		text

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

  1. Ensure navigation.instant is active in the config.
  2. Ensure that admonitions is configured in the config.
  3. Create a collapsible admonition with a header element nested within (example in bug section or below here) on a page of your choice
  4. Spin up mkdocs serve or build
  5. Navigate to localhost:8000 or open index.html on Safari or Firefox
  6. Using Safari or Firefox // on the page try and navigate to a header nested within an admonition (samples available in repro zip file)

Expected 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:

??? bug "Title of Admonition"
		### header

		text

Browser

Safari, Firefox

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions