mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2026-10-15 02:42:01 -05:00
Only change current if a matching link is found (#472)
This commit is contained in:
1 parent
896fe3ee16
commit
ee4d440375
1 file changed
+8
-6
+8
-6
@@ -108,13 +108,15 @@ function ThemeNav () {
|
||||
// Try again with the closest section entry.
|
||||
link = $('.wy-menu-vertical')
|
||||
.find('[href="#' + closest_section.attr("id") + '"]');
|
||||
|
||||
}
|
||||
$('.wy-menu-vertical li.toctree-l1 li.current')
|
||||
.removeClass('current');
|
||||
link.closest('li.toctree-l2').addClass('current');
|
||||
link.closest('li.toctree-l3').addClass('current');
|
||||
link.closest('li.toctree-l4').addClass('current');
|
||||
// If we found a matching link then reset current and re-apply
|
||||
// otherwise retain the existing match
|
||||
if (link.length > 0) {
|
||||
$('.wy-menu-vertical li.toctree-l1 li.current').removeClass('current');
|
||||
link.closest('li.toctree-l2').addClass('current');
|
||||
link.closest('li.toctree-l3').addClass('current');
|
||||
link.closest('li.toctree-l4').addClass('current');
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log("Error expanding nav for anchor", err);
|
||||
|
||||
Reference in new issue
Block a user