From a6a947ccabe864a4d02076de9e2277f03f49d361 Mon Sep 17 00:00:00 2001 From: Botato <51982229+Botato300@users.noreply.github.com> Date: Sun, 29 Mar 2026 21:39:38 -0300 Subject: [PATCH] fix(docs): avoid scrolling to bottom when active sidebar link is not found --- src/generators/legacy-html/assets/api.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/generators/legacy-html/assets/api.js b/src/generators/legacy-html/assets/api.js index da3f7522..0678c52f 100644 --- a/src/generators/legacy-html/assets/api.js +++ b/src/generators/legacy-html/assets/api.js @@ -203,18 +203,19 @@ const setupCopyButton = () => { function setupSidebarScroll() { const sidebarLinks = document.querySelectorAll('#column2 a'); - let link; - for (link of sidebarLinks) { + let activeLink = null; + for (const link of sidebarLinks) { if (link.pathname === window.location.pathname) { + activeLink = link; break; } } - if (!link) { + if (!activeLink) { return; } - link.scrollIntoView({ behavior: 'smooth', block: 'center' }); + activeLink.scrollIntoView({ behavior: 'smooth', block: 'center' }); } // Initialize either on DOMContentLoaded or immediately if already loaded