From 729f136fb0d14599b4761660fcb915cb15d6042e Mon Sep 17 00:00:00 2001 From: Julian Wiest Date: Fri, 7 Nov 2025 21:15:08 +0100 Subject: [PATCH] Add offset option to scrollspy initialization (#3354) ## Fix ToC Scroll-Spy Highlighting Issue ### Problem When clicking on a ToC link in the sidebar, the page scrolls to the correct section, but the ToC highlights the *previous* section instead of the current one. The correct section only gets highlighted after scrolling down a few pixels. ### Root Cause The `scrollspy` in `assets/js/common.js` was initialized without an offset parameter, so it didn't account for the fixed navigation header height (~56px). ### Solution Added `offset: 100` parameter to the scrollspy initialization to properly detect when a section becomes visible, accounting for the header and some buffer space. ### Changes - Modified `assets/js/common.js`: Added offset parameter to scrollspy configuration ### Testing - [x] ToC correctly highlights the current section immediately after clicking - [x] Headings remain visible (not hidden under header) - [x] Smooth scrolling works as expected --------- Co-authored-by: Maruan --- assets/js/common.js | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/js/common.js b/assets/js/common.js index a2088c3..6f3fa49 100644 --- a/assets/js/common.js +++ b/assets/js/common.js @@ -28,6 +28,7 @@ $(document).ready(function () { Toc.init($myNav); $("body").scrollspy({ target: navSelector, + offset: 100, }); }