From c5645ad1d44f00ac3db2ec92ee6b78d8aa17da41 Mon Sep 17 00:00:00 2001 From: Botato <51982229+Botato300@users.noreply.github.com> Date: Sat, 25 Oct 2025 15:19:51 -0300 Subject: [PATCH 1/2] feat(docs): keep sidebar module visible when navigating docs --- doc/api_assets/api.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/api_assets/api.js b/doc/api_assets/api.js index e86f110e0346bf..36ef510130dbd3 100644 --- a/doc/api_assets/api.js +++ b/doc/api_assets/api.js @@ -187,6 +187,20 @@ }); } + function setupSidebarScroll() { + const sidebar = document.querySelector('#column2'); + if (!sidebar) return; + + const currentModule = window.location.pathname.split('/').pop(); + if (!currentModule) return; + + const link = sidebar.querySelector(`a[href="${currentModule}"]`); + if (!link) return; + + link.scrollIntoView({ block: 'center' }); + } + + function bootstrap() { // Check if we have JavaScript support. document.documentElement.classList.add('has-js'); @@ -206,6 +220,8 @@ setupFlavorToggles(); setupCopyButton(); + + setupSidebarScroll(); } if (document.readyState === 'loading') { From e0a6c022031460218485d2692cdcedd9b664ca9a Mon Sep 17 00:00:00 2001 From: Botato300 Date: Sat, 8 Nov 2025 20:53:35 -0300 Subject: [PATCH 2/2] doc: optimizes and simplifies the setupSidebarScroll() function --- doc/api_assets/api.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api_assets/api.js b/doc/api_assets/api.js index 36ef510130dbd3..a3e479ed9569c3 100644 --- a/doc/api_assets/api.js +++ b/doc/api_assets/api.js @@ -188,15 +188,15 @@ } function setupSidebarScroll() { - const sidebar = document.querySelector('#column2'); - if (!sidebar) return; + const sidebarLinks = document.querySelectorAll('#column2 a'); - const currentModule = window.location.pathname.split('/').pop(); - if (!currentModule) return; + let link; + for (link of sidebarLinks) { + if (link.pathname === window.location.pathname) break; + } - const link = sidebar.querySelector(`a[href="${currentModule}"]`); if (!link) return; - + link.scrollIntoView({ block: 'center' }); }