Skip to content

Commit c5645ad

Browse files
authored
feat(docs): keep sidebar module visible when navigating docs
1 parent 790489c commit c5645ad

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 sidebar = document.querySelector('#column2');
192+
if (!sidebar) return;
193+
194+
const currentModule = window.location.pathname.split('/').pop();
195+
if (!currentModule) return;
196+
197+
const link = sidebar.querySelector(`a[href="${currentModule}"]`);
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)