From f12a96b7faecd2ced5c6643778e06614f5ef7251 Mon Sep 17 00:00:00 2001 From: James Reid-Smith Date: Tue, 17 Dec 2024 19:07:30 -0500 Subject: [PATCH] Auto-hide navigation on link click (#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. --- 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; + } + }); } }