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 does not work with section anchors in Safari #3797

Closed
5 tasks done
ybizeul opened this issue Apr 4, 2022 · 19 comments · Fixed by #5032
Closed
5 tasks done

Instant loading does not work with section anchors in Safari #3797

ybizeul opened this issue Apr 4, 2022 · 19 comments · Fixed by #5032
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@ybizeul
Copy link

ybizeul commented Apr 4, 2022

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

Beginning with version 7.0.0 anchors defined on headings do not work with Safari 15.4 macOS

Expected behaviour

Clicking the the link on the TOC should jump to the section in the main content
Using a URL with # anchor should open the page at the location.

Actual behaviour

Page stays on top

Steps to reproduce

Run website and click on a H3 link on the right side

Package versions

  • Python: Python 3.8.7
  • MkDocs: mkdocs, version 1.1.2 from /usr/local/lib/python3.8/site-packages/mkdocs (Python 3.8)
  • Material: 7.0.0

Configuration

site_name: Test Site
nav:
  - Home: /
theme:
  name: material
  features:
     - navigation.instant
markdown_extensions:
  - toc:
      permalink:

System information

  • Operating system: macOS 12.3.1
  • Browser: Safari 15.4
@squidfunk squidfunk added the needs investigation Issue must be investigated by the maintainers label Apr 4, 2022
@squidfunk
Copy link
Owner

Thanks for reporting. The readthedocs theme is probably an error in your configuration, right?

@ybizeul
Copy link
Author

ybizeul commented Apr 4, 2022

Ah yes I was testing with the readthedoc theme but couldn't make it to apply not sure why.

Fixing it

@squidfunk
Copy link
Owner

Thanks! Instant loading is a feature of Material for MkDocs. The readthedocs theme has no support for it.

@ybizeul ybizeul changed the title Anchors on heading sections not working with navigation.instant Anchors on heading sections not working on Safari with navigation.instant Apr 4, 2022
@squidfunk
Copy link
Owner

squidfunk commented Apr 4, 2022

I'm not able to reproduce what you are describing. Anchors within the page, as well as anchors between pages work for me:

Ohne.Titel.mp4

Please provide a screencast and explain exactly what you're observing. Either I'm not yet understanding the issue you're reporting, or it does not reproduce. Note that I only have Safari 15.2 on my hands, so it might be related to that.

Furthermore, when you encounter the issue, please open the console and check if an error occurred. It might also be related to something entirely different, i.e. an error in third-party JavaScript.

@squidfunk squidfunk added needs input Issue needs further input by the reporter needs reproduction Issue lacks a minimal reproduction .zip file and removed needs investigation Issue must be investigated by the maintainers needs input Issue needs further input by the reporter labels Apr 4, 2022
@ybizeul
Copy link
Author

ybizeul commented Apr 4, 2022

Enregistrement.de.l.ecran.2022-04-04.a.19.44.47.mp4

@squidfunk
Copy link
Owner

squidfunk commented Apr 5, 2022

Thanks for providing the screencast! Unfortunately, it's still not reproducible for me.

  • Is there anything printed in the console?
  • Could you please provide a self-contained example? You can just zip your project and attach it here

@ybizeul
Copy link
Author

ybizeul commented Apr 5, 2022

You can see the console in the screencast, nothing special.
mkdocs-materials-anchors 2.zip

@squidfunk
Copy link
Owner

squidfunk commented Apr 5, 2022

I meant the browser's console 😉 Sorry for not being clear.

@ybizeul
Copy link
Author

ybizeul commented Apr 5, 2022

Ah sorry ! Nothing in the console

@ybizeul
Copy link
Author

ybizeul commented Apr 6, 2022

Were you able to reproduce the issue ?

@squidfunk
Copy link
Owner

Unfortunately not. I've tested with 7.0.0 and 8.2.8 (latest). Both are working fine. Here's a screencast with 8.2.8.:

Ohne.Titel.mp4

I'm afraid I can't put any more time into this issue, it just does not reproduce for me. I tried everything. If other users are having the same problem in the future, maybe we can find a way to create a reproduction, but this one just doesn't do it. Note that I'm running Safari 15.2 (not the latest 15.4), so it might be related to that, but until now it seems you're the only one with this problem. I'm closing this issue as not reproducible for now.

@ybizeul
Copy link
Author

ybizeul commented Apr 6, 2022

So you're not even trying to reload the page and see if it gets to the anchor ? That's what I explain in my screencast

It might be an issue with Safari 15.4 I guess.

@squidfunk squidfunk reopened this Apr 6, 2022
@squidfunk
Copy link
Owner

Oh, sorry, I missed the reload. It wasn't apparent in your screencast and you did not mention it explicitly. I can reproduce it when reloading. Reopened. I'll look into it when I find some time!

@squidfunk squidfunk added bug Issue reports a bug and removed needs reproduction Issue lacks a minimal reproduction .zip file labels Apr 6, 2022
@squidfunk
Copy link
Owner

So, a heads up: I'm aware of this issue, but solving it turns out to be very complex. I'm going to take this as an opportunity to refactor instant loading, which definitely needs to be simplified, also solving the issue at hand. However, I need to find enough time to do this, so I currently can't put an estimate on when this will be fixed.

In the meantime, disabling instant loading is a good workaround.

@ybizeul
Copy link
Author

ybizeul commented Apr 24, 2022

That’s what I did. Thanks for looking into this !

@squidfunk squidfunk changed the title Anchors on heading sections not working on Safari with navigation.instant Instant loading does not work with section anchors in Safari May 6, 2022
doughahn added a commit to doughahn/unofficial-opf-guides that referenced this issue May 7, 2022
“So, a heads up: I'm aware of this issue, but solving it turns out to be very complex. I'm going to take this as an opportunity to refactor instant loading, which definitely needs to be simplified, also solving the issue at hand. However, I need to find enough time to do this, so I currently can't put an estimate on when this will be fixed.

In the meantime, disabling instant loading is a good workaround.”

— squidfunk/mkdocs-material#3797 (comment)
@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

@feasgal
Copy link

feasgal commented Feb 13, 2023

I've had navigation.instant disabled for the last year due to the same issue. I tried the fix you linked yesterday. It seemed to solve the issue.

  1. Enabled navigation.instant and checked to be sure the bug was still occurring in Safari.

    • It was. Anchor links did not work in Safari.
  2. Uninstalled and reinstalled using the command line you supplied.

  3. Checked to see if the anchor links now worked in Safari.

    • They did.

I didn't have time to thoroughly regression-test or anything.

@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.

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

Successfully merging a pull request may close this issue.

3 participants