summaryrefslogtreecommitdiff
path: root/lib/rdoc/generator/template/darkfish/js
diff options
context:
space:
mode:
authorJames Reid-Smith <[email protected]>2024-12-17 19:07:30 -0500
committerHiroshi SHIBATA <[email protected]>2024-12-19 08:45:31 +0900
commita920808c4bf1bfa802d46c86993adfd7313459d4 (patch)
treef5116b138dc655d21e3f2feb322a521095153954 /lib/rdoc/generator/template/darkfish/js
parent35ff04ce5ee3f4758fbde1ff2940161b02b05527 (diff)
[ruby/rdoc] Auto-hide navigation on link click
(https://github.com/ruby/rdoc/pull/1238) Hide navigation sidebar when clicking anchor links on mobile devices. Previously, anchor links would change the page but the navigation sidebar would block the view. https://github.com/ruby/rdoc/commit/f12a96b7fa
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12394
Diffstat (limited to 'lib/rdoc/generator/template/darkfish/js')
-rw-r--r--lib/rdoc/generator/template/darkfish/js/darkfish.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js
index ed3893379d..4c15efde66 100644
--- a/lib/rdoc/generator/template/darkfish/js/darkfish.js
+++ b/lib/rdoc/generator/template/darkfish/js/darkfish.js
@@ -103,6 +103,12 @@ function hookSidebar() {
if (isSmallViewport) {
navigation.hidden = true;
navigationToggle.ariaExpanded = false;
+ document.addEventListener('click', (e) => {
+ if (e.target.closest('#navigation a')) {
+ navigation.hidden = true;
+ navigationToggle.ariaExpanded = false;
+ }
+ });
}
}