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

toc.follow not respected: right sidebar does not scroll or show "passed" items #380

Open
melissawm opened this issue Aug 5, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@melissawm
Copy link

With a vanilla set up of this theme, the toc.follow feature seems to not be respected. The right sidebar does not scroll when the page has a large number of items, and there is no difference between items that have "passed", active items and items further down in the page.

I am probably doing something wrong, but can't detect what it is from the docs.

Here's how that looks:

immaterial

And here's the source code: https://github.com/melissawm/minimalsphinx

Any help would be appreciated. Thanks!

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 5, 2024

It looks like you're using firefox in the picture. Is this behavior also observed in chrome?

@melissawm
Copy link
Author

Yes, it's exactly the same on chrome. Also, I do see the effect in the deployed documentation for sphinx-immaterial, which is why I was expecting this to work at all.

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 6, 2024

Can you point me to the page in our docs? I haven't seen this behavior. I tried quickly reproducing this locally but was unsuccessful.

@melissawm
Copy link
Author

Oh I mean in your docs it works correctly in my browser 😄 See, for example, here: https://sphinx-immaterial.readthedocs.io/en/latest/admonitions.html

I am happy to help debug and submit a PR. I know this is coming in some way from mkdocs-material and if you can point me to the entry point for this functionality I might be able to take a look. Inspecting the code, I see that your pages are rendered with each item in the sidebar with class md-nav__link md-nav__sticky - even when using toc.follow (or toc.sticky) I never get my elements to show md-nav__sticky so I assume something is going wrong there.

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 6, 2024

Does adding toc.sticky feature relieve the issue?

@melissawm
Copy link
Author

Unfortunately no, same behavior.

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 6, 2024

Hmm, IIRC the current implementation for the toc.follow feature is inherited from upstream mkdocs-material implementation. There might be some modifications on our end.

@melissawm
Copy link
Author

Oh wow, I found it. It's the palette: if it's not set, the scrollbar does not appear and the names are not highlighted accordingly. Would it be ok if I checked to see if having a default palette be applied (when it is unset) would solve the issue?

@jbms
Copy link
Owner

jbms commented Aug 6, 2024

Yes that sounds good, thanks.

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 6, 2024

I looked for upstream issues that might be related.

It might be worth adding a default value for the palette in

DEFAULT_THEME_OPTIONS = {
"features": [],
"font": {"text": "Roboto", "code": "Roboto Mono"},
"plugins": {
"search": {},
},
"icon": {},
"repo_url": "",
"edit_uri": "",
"globaltoc_collapse": True,
"toc_title": None,
"toc_title_is_page_title": False,
}

The only disadvantage I can think of is our copying of the minified CSS specifically for the color palette. If no palette is specified, then the CSS is not copied to the build output. So adding a default value for the color palette would also suggest we don't conditionally copy the CSS and instead include it unconditionally.

theme_options = app.config["html_theme_options"]
if theme_options and "palette" in theme_options:
css_entries.append(
Entry(
code=(theme_bundles / "palette.css").read_text(encoding="utf-8"),
sourcemap=(theme_bundles / "palette.css.map").read_text(
encoding="utf-8"
),
priority=200,
)
)

@2bndy5 2bndy5 added the bug Something isn't working label Aug 6, 2024
@melissawm
Copy link
Author

The other alternative would be to add a note to the documentation about this behavior.

@2bndy5
Copy link
Collaborator

2bndy5 commented Sep 11, 2024

The doc option would be easier. A PR is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants