Skip to content

Commit aa948fd

Browse files
authored
doc: keep sidebar module visible when navigating docs
PR-URL: #60410 Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 1758b74 commit aa948fd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/api_assets/api.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,20 @@
187187
});
188188
}
189189

190+
function setupSidebarScroll() {
191+
const sidebarLinks = document.querySelectorAll('#column2 a');
192+
193+
let link;
194+
for (link of sidebarLinks) {
195+
if (link.pathname === window.location.pathname) break;
196+
}
197+
198+
if (!link) return;
199+
200+
link.scrollIntoView({ block: 'center' });
201+
}
202+
203+
190204
function bootstrap() {
191205
// Check if we have JavaScript support.
192206
document.documentElement.classList.add('has-js');
@@ -206,6 +220,8 @@
206220
setupFlavorToggles();
207221

208222
setupCopyButton();
223+
224+
setupSidebarScroll();
209225
}
210226

211227
if (document.readyState === 'loading') {

0 commit comments

Comments
 (0)