Skip to content

Commit 2e97557

Browse files
committed
Attach sidebar-close handler to current-page links
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
1 parent cf898d3 commit 2e97557

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sphinx_rtd_theme/static/js/theme.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/theme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function ThemeNav () {
8686
})
8787

8888
// Nav menu link click operations
89-
.on('click', ".wy-menu-vertical .current ul li a", function() {
89+
.on('click', ".wy-menu-vertical ul li a[href^='#']", function() {
9090
var target = $(this);
9191
// Close menu when you click a link.
9292
$("[data-toggle='wy-nav-shift']").removeClass("shift");

0 commit comments

Comments
 (0)