squidfunk / mkdocs-material

Documentation that simply works
https://squidfunk.github.io/mkdocs-material/
MIT License
19.09k stars 3.39k forks source link

Instant navigation: toc item requires two clicks after navigating away and returning #7183

Closed rachel-rigdon-sp closed 1 month ago

rachel-rigdon-sp commented 1 month ago

Context

No response

Bug description

When using Instant Loading, selecting a link in the table of contents, navigating away, returning, and then selecting the same toc item does not jump to the id until the second click.

I've confirmed this in Chrome, Firefox, and Edge.

Related links

Reproduction

9.5.22+insiders.4.53.8-instant-nav-bug-repro.zip

Steps to reproduce

  1. Select a right-side toc item.
  2. Use the left-side navigation to go to another page.
  3. Use the left-side navigation to return to the first page.
  4. Select the same right-side toc item. It now requires two clicks to navigate to.

Browser

No response

Before submitting

squidfunk commented 1 month ago

Thanks for reporting! I'll investigate.

squidfunk commented 1 month ago

Fixed in 485fa76fbc086f9b99f2291fbc0c6052c5a32d79! Thanks for the excellent issue and reproduction, that made isolating and fixing the issue really easy. The problem was that the pathname change was not properly detected, which is now ensured by the document$ subscription and the double switch map on location$. The comment explains how it works:

https://github.com/squidfunk/mkdocs-material/blob/485fa76fbc086f9b99f2291fbc0c6052c5a32d79/src/templates/assets/javascripts/integrations/instant/index.ts#L366-L378

Perfect issue! Thanks for taking the time.

rachel-rigdon-sp commented 1 month ago

Thank you so much for the fix! 🙌🏻

squidfunk commented 1 month ago

Released as part of 9.5.23.

soronpo commented 1 month ago

Thank you so much!