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 loading not allowing to go back to initial page #5023

Closed
4 tasks done
vedranmiletic opened this issue Feb 10, 2023 · 10 comments · Fixed by #5032
Closed
4 tasks done

Instant loading not allowing to go back to initial page #5023

vedranmiletic opened this issue Feb 10, 2023 · 10 comments · Fixed by #5032
Labels
bug Issue reports a bug 🏆 perfect Issue is of outstanding quality resolved Issue is resolved, yet unreleased if open

Comments

@vedranmiletic
Copy link
Contributor

Context

No response

Bug description

Going back to a page via browser back button with Instant loading enabled in general works fine. However, going back via browser back button to the the first page that was loaded doesn't work. To illustrate the idea:

  • user types https://gaseri.org/en/ in the location bar (first page)
  • navigates to https://gaseri.org/en/introductory-presentation/ via the link in the navigation bar (second page)
  • navigates to https://gaseri.org/en/people/principal-investigator/ via the link in the navigation bar (third page)
  • user presses browser back button, goes from third to second page and URL https://gaseri.org/en/introductory-presentation/ and its contents load fine as expected
  • user presses browser back button, goes from second to first page and URL changes to https://gaseri.org/en/ in the location bar, but the contents of https://gaseri.org/en/introductory-presentation/ are still shown

This is just to illustrate what is working and what is not; my minimal example attached below has only two pages that reproduce the issue.

I tested latest versions of Firefox and Brave, same issue. Finally, this is a regression from introduced in 9.0.0b1 and later versions of Material for MkDocs; version 8.5.11 works fine.

Related links

Reproduction

example.zip

Steps to reproduce

  1. Run mkdocs serve
  2. Open http://127.0.0.1:8000/ in browser
  3. Click on link to Page 1
  4. Click back button in browser to go back to index page
  5. Browser keeps displaying the contents of Page 1

Browser

No response

Before submitting

@squidfunk squidfunk changed the title Going back to the first page loaded via browser back button doesn't work with Instant loading enabled Instant loading not allowing to go back to initial page Feb 10, 2023
@squidfunk squidfunk added the needs investigation Issue must be investigated by the maintainers label Feb 10, 2023
@squidfunk
Copy link
Owner

So first of all, thanks for reporting and the excellent reproduction and for checking in which version the regression was introduced – you definitely invested time into this, which is invaluable for us maintainers. This is also why we award this bug report the 🏆 perfect badge, the first time ever!

Now to the bug: I checked 8.5.11 vs 9.0.0b1 and yes, I can observe the same behavior. However, there were absolutely no changes on instant loading between those versions, which is why I believe that this is a bug that now somehow manifests because new behavior was added somewhere else. There were a lot of changes in version 9, so it's not surprising. Instant loading is in need of refactoring, which we will tackle later this year.

I think I have a fix in 329d26d. If that's true, then it's clearly of the category "how did that ever work", because when you first visit the page, the state is obviously null, which was filtered from propagating. This happens when you visit the page and navigate to the next page without scrolling. Please check if that fixes the issue.

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open 🏆 perfect Issue is of outstanding quality and removed needs investigation Issue must be investigated by the maintainers labels Feb 10, 2023
@squidfunk
Copy link
Owner

The last commit introduced another small bug: when you click an anchor on the same page, the page jumps back to the top. This is now fixed in f480bb2. As said, we need to refactor instant loading.

@squidfunk
Copy link
Owner

Okay, never mind... there are still problems with the fixes applied. I think this may take longer since all browsers seem to behave differently 😅 I'll try to fix this on the weekend.

@squidfunk squidfunk removed the resolved Issue is resolved, yet unreleased if open label Feb 10, 2023
@squidfunk
Copy link
Owner

I've reverted both commits. I'll tackle this together with #3797.

@squidfunk
Copy link
Owner

#5032 contains a refactoring of instant loading. I'm not sure that it's finished yet, but if you find some time for testing, that would be amazing. You can install it with:

pip install git+https://github.com/squidfunk/mkdocs-material.git@refactor/instant-loading

@vedranmiletic
Copy link
Contributor Author

The reported issue seems fixed. Thanks!

However, there is an interesting corner case I just noticed. If you navigate to a page and press refresh button and then press back, it does not work correctly (URL gets updated, but contents stay the same). Is this also fixable?

@squidfunk
Copy link
Owner

I'll look into it.

@squidfunk
Copy link
Owner

The issues should be fixed in #5023. I've taken the time and did a complete rewrite of instant loading. It should be much more stable now. I'll issue a new release shortly, so we can find any remaining bugs quickly, but I'm quite confident that scroll restoration should work much better now. I've tested in Chrome, Firefox and Safari.

@squidfunk
Copy link
Owner

Released as part of 9.1.1.

@vedranmiletic
Copy link
Contributor Author

It works great. Thank you, @squidfunk!

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

Successfully merging a pull request may close this issue.

2 participants