Bug#1075914: developers-reference: issue with sidebar in singlehtml variant on small screens
Followup-For: Bug #1075914
X-Debbugs-Cc: hwansing@mailbox.org
Control: reassign -1 src:sphinx-rtd-theme
Control: affects -1 developers-reference
Control: tags -1 patch
This seems to relate to the Sphinx ReadTheDocs theme, and when I went digging
around in the code there, it seemed that there is already a JavaScript event
handler[1] in 'theme.js' that is intended to close the sidebar menu when a
hyperlink is clicked. It seems that that handler isn't being called.
For multi-page HTML projects, that's generally not a problem because the
browser opens the requested link page and rebuilds the DOM, applies CSS etc
from scratch - and the sidebar is closed by default, so it appears to the user
that the click/navigation closed it.
The root cause seems to be something to do with the CSS select query that is
used to attach the event handler. I'm attaching a patch that resolved the
issue when I tested it locally -- and should be compatible with the Debian
package build.
It would be nice to figure out whether the CSS query worked in the past;
perhaps this bug is a regression.
[1] - https://sources.debian.org/src/sphinx-rtd-theme/2.0.0%2Bdfsg-1/src/theme.js/#L88-L97
commit c34a308ef0afe4882d27498593028e94c7d58578
Author: James Addison <jay@jp-hosting.net>
Date: Tue Jul 9 13:35:16 2024 +0100
JavaScript: attach sidebar close-on-click handler to all menu hyperlinks.
diff --git a/src/theme.js b/src/theme.js
index db546b4..b66a54e 100644
--- a/src/theme.js
+++ b/src/theme.js
@@ -86,7 +86,7 @@ function ThemeNav () {
})
// Nav menu link click operations
- .on('click', ".wy-menu-vertical .current ul li a", function() {
+ .on('click', ".wy-menu-vertical ul li a", function() {
var target = $(this);
// Close menu when you click a link.
$("[data-toggle='wy-nav-shift']").removeClass("shift");
Reply to: