Skip to content
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

Instant navigation: TOC items on visited pages require two clicks #7924

Closed
4 tasks done
Nerixyz opened this issue Jan 20, 2025 · 7 comments
Closed
4 tasks done

Instant navigation: TOC items on visited pages require two clicks #7924

Nerixyz opened this issue Jan 20, 2025 · 7 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@Nerixyz
Copy link

Nerixyz commented Jan 20, 2025

Context

This is very similar to #7183, except that the user doesn't navigate back to the main page but clicks a heading on the visited page, which requires two clicks.

Bug description

When navigation.instant is enabled, jumping to headings using the TOC on "new"/"child" pages requires two clicks.

Related links

Reproduction

9.5.50-instant-navigation-bug-2.zip

Steps to reproduce

  1. Go to the main/index page
  2. Visit the second page through the navigation on the left
  3. On the second page, click on a link in the TOC on the right. This requires two clicks.

Browser

No response

Before submitting

@squidfunk
Copy link
Owner

Thanks for reporting. I can reproduce the issue. We'll look into it.

@squidfunk squidfunk added the bug Issue reports a bug label Jan 21, 2025
@squidfunk
Copy link
Owner

Okay, I think I've isolated the problem. The pipeline that is in effect when a document was loaded (initial load, or subsequent instant load) always resubscribes to location changes after this happened, in order to detect anchor-only changes (clicking a link in the TOC). I assumed that we need a two-layer subscription here, first filtering on the pathname (= page navigation), and then filtering on the hash fragment (= anchor navigation). This doesn't seem to be true, since removing the first part of the pipeline fixes the issue, as the pathname navigation already happened when the document observable emitted. We seem to be good just filtering distinct hash fragments. It might turn out not to be true once we release this fix, with some other issue re-appearing, but my current guess is that it should be fine. This is also exceptionally hard to test, since browsers are different.

Fixed in 07a434b.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Jan 21, 2025
@squidfunk
Copy link
Owner

@Nerixyz could you please confirm that this fixes your issue?

@pajlada
Copy link

pajlada commented Jan 23, 2025

I created a fresh venv, installed the version with the fix with pip install git+ssh://[email protected]/squidfunk/mkdocs-material.git@07a434b465aafc1ac228d9f2b7bd8c8f3ac81dda and can confirm it fixes the issue for me

@Nerixyz
Copy link
Author

Nerixyz commented Jan 23, 2025

@Nerixyz could you please confirm that this fixes your issue?

Both this and the reproduction from #7183 work now, thank you!

@Nerixyz Nerixyz closed this as completed Jan 23, 2025
@squidfunk
Copy link
Owner

Thanks for confirming. Keeping open until released.

@squidfunk squidfunk reopened this Jan 23, 2025
@squidfunk
Copy link
Owner

Released as part of 9.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

3 participants