Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinx_rtd_theme/static/js/theme.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,15 @@ function ThemeNav () {
.addClass('current')
.attr('aria-expanded','true');
}
link[0].scrollIntoView();
/* Scroll the link's top-level parent into view first. Then
* scroll the link itself into view, which will only have an
* effect if the top-level parent is taller than the viewport
* and the link is still outside the viewport after the first
* scroll. (This seems likely to be rare.)
*/
link.closest('li.toctree-l1')[0]
.scrollIntoView({block: "nearest"});
link[0].scrollIntoView({block: "nearest"});
}
}
catch (err) {
Expand Down