From 1d8ae267d613d957b5777f481c9de3d38567c5b8 Mon Sep 17 00:00:00 2001 From: James Reid-Smith Date: Fri, 13 Dec 2024 13:57:34 -0500 Subject: [PATCH] Auto-hide navigation on link click 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. --- lib/rdoc/generator/template/darkfish/js/darkfish.js | 6 ++++++ 1 file changed, 6 insertions(+) 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; + } + }); } }