You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
... 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
As discussed previously, I went ahead and added custom anchors to the page's TOC.
Unfortunately, when scrolling down, anchors that reside within a <table> are not tracked correctly.
From what I've seen, src/assets/javascripts/components/toc/index.ts is responsible for this functionality. Maybe somewhere starting from Line #158? Unfortunately, it's above my level of expertise to understand where the strange behaviour is coming from.
Expected behaviour
Within the TOC, the section currently in view should be highlighted.
Actual behaviour
This does work only for anchors that DO NOT reside within a <table>. Those behave absolutely correctly.
But with those inside a <table> it is strange: is the page scrolled to the very top, an anchor from within the table is highlighted as active - even though it's not in view. And once you start scrolling, those anchors apparently get ignored.
Steps to reproduce
Result:
Just take a look at my example page. This is a minimal project to demo this problem.
Using the customAnchors.py hook, I look for <strong> tags containing the id="..." attribute. Those get added to the TOC.
With the mkdoc's default theme, everything works as expected (clone the repo and remove the material theme definition from the config
Package versions
Python: 3.9.4
MkDocs: 1.4.0
Material: 8.5.3
Configuration
# Can be found here: https://github.com/mh166/mkdocs-custom-anchors/blob/main/mkdocs.ymlsite_name: "Demo: problem with anchors within tables"theme:
name: materialmarkdown_extensions:
- attr_listcopyright: mh166extra_css:
- extra.csshooks:
- customAnchors.py
System information
I've tried on Windows 10 using multiple browsers (Chrome, Edge, Opera). All show the same behaviour.
The text was updated successfully, but these errors were encountered:
Thanks for reporting. So yes, it's a bug which stems from the problem that the offset in tables is relative to the table, not to the page. That's actually related to #3453 and #4217. I need some time to generalize the fix, which will also fix this problem.
Fixed in 318903d. Thanks for the excellent reproduction – that made fixing quite simple. I'll revisit how we can generalize offset computation once annotations are released into the community edition once the next funding goal is hit, which I expect to be in February or March. 😊
Releasing a new feature always yields significant refactoring opportunities, like for search recently. Related:
Thanks so much! Glad my example was of help. I'm excited to try this next week and roll back some of my hacky workarounds (mostly visually disabling the tracking... 😅).
Please keep up the great work you do! This project is absolutely amazing! ✨
Contribution guidelines
I've found a bug and checked that ...
mkdocs
orreadthedocs
themescustom_dir
,extra_javascript
andextra_css
Description
As discussed previously, I went ahead and added custom anchors to the page's TOC.
Unfortunately, when scrolling down, anchors that reside within a
<table>
are not tracked correctly.From what I've seen, src/assets/javascripts/components/toc/index.ts is responsible for this functionality. Maybe somewhere starting from Line #158? Unfortunately, it's above my level of expertise to understand where the strange behaviour is coming from.
Expected behaviour
Within the TOC, the section currently in view should be highlighted.
Actual behaviour
This does work only for anchors that DO NOT reside within a
<table>
. Those behave absolutely correctly.But with those inside a
<table>
it is strange: is the page scrolled to the very top, an anchor from within the table is highlighted as active - even though it's not in view. And once you start scrolling, those anchors apparently get ignored.Steps to reproduce
Result:
Try for yourself:
customAnchors.py
hook, I look for<strong>
tags containing theid="..."
attribute. Those get added to the TOC.mkdoc
's default theme, everything works as expected (clone the repo and remove the material theme definition from the configPackage versions
3.9.4
1.4.0
8.5.3
Configuration
System information
I've tried on Windows 10 using multiple browsers (Chrome, Edge, Opera). All show the same behaviour.
The text was updated successfully, but these errors were encountered: