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

Attach sidebar-close handler to current-page links #1588

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jayaddison
Copy link

This is intended primarily to resolve a problem with singlehtml documentation projects when viewed on narrow (typically mobile) displays.

Under those circumstances, the .current CSS selector does not match any sidebar menu elements, because there is no logical notion of a 'current' page in singlehtml -- every item is on the same page.

Therefore this change proposes an alternative way to identify sidebar links that are 'current' -- it checks for anchors that have an href beginning with the query-string fragment identifier (#).

This is intended to be compatible with both singlehtml and html project builds. It depends upon sphinx-doc/sphinx#12551

Resolves #880.

@jayaddison jayaddison requested a review from a team as a code owner August 12, 2024 11:59
@jayaddison

This comment was marked as resolved.

@jayaddison jayaddison marked this pull request as draft August 17, 2024 11:42
This is intended primarily to resolve a problem with `singlehtml`
documentation projects when viewed on narrow (typically mobile)
displays.

Under those circumstances, the `.current` CSS selector does not
match any sidebar menu elements, because there is no logical notion
of a 'current' page in `singlehtml` -- every item is on the same
page.

Therefore this change proposes an alternative way to identify sidebar
links that are 'current' -- it checks for anchors that have an `href`
beginning with the query-string fragment identifier (`#`).

This is intended to be compatible with both `singlehtml` and `html`
project builds.  It depends upon sphinx-doc/sphinx#12551
@jayaddison jayaddison force-pushed the issue-880/singlehtml-sidebar-css-selection branch from 2e97557 to 9d30f9e Compare October 15, 2024 11:23
@jayaddison
Copy link
Author

Rebased against sphinx_rtd_theme v3.0.1, and rebuilt the theme.js file since previous commit -- no changes.

Test results when self-building the sphinx_rtd_theme documentation (in this repo) using Sphinx v8.1.3:

Before (buggy)

buggy.mp4

After (fixed)

fixed.mp4

@jayaddison jayaddison marked this pull request as ready for review October 15, 2024 18:16
@jayaddison
Copy link
Author

Note: based on the dependency deprecation history for the project, I'd anticipate that the very earliest that this could be merged would likely be for a 4.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navigation problems with singlehtml output
1 participant