From aa948fdbd0120fdac704f2a38342dca4037f7cd8 Mon Sep 17 00:00:00 2001 From: Botato <51982229+Botato300@users.noreply.github.com> Date: Sun, 23 Nov 2025 13:20:07 +0000 Subject: [PATCH] doc: keep sidebar module visible when navigating docs PR-URL: https://github.com/nodejs/node/pull/60410 Reviewed-By: Antoine du Hamel --- 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 e86f110e03..a3e479ed95 100644 --- a/doc/api_assets/api.js +++ b/doc/api_assets/api.js @@ -187,6 +187,20 @@ }); } + function setupSidebarScroll() { + const sidebarLinks = document.querySelectorAll('#column2 a'); + + let link; + for (link of sidebarLinks) { + if (link.pathname === window.location.pathname) break; + } + + 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') {