File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -108,13 +108,15 @@ function ThemeNav () {
108108 // Try again with the closest section entry.
109109 link = $ ( '.wy-menu-vertical' )
110110 . find ( '[href="#' + closest_section . attr ( "id" ) + '"]' ) ;
111-
112111 }
113- $ ( '.wy-menu-vertical li.toctree-l1 li.current' )
114- . removeClass ( 'current' ) ;
115- link . closest ( 'li.toctree-l2' ) . addClass ( 'current' ) ;
116- link . closest ( 'li.toctree-l3' ) . addClass ( 'current' ) ;
117- link . closest ( 'li.toctree-l4' ) . addClass ( 'current' ) ;
112+ // If we found a matching link then reset current and re-apply
113+ // otherwise retain the existing match
114+ if ( link . length > 0 ) {
115+ $ ( '.wy-menu-vertical li.toctree-l1 li.current' ) . removeClass ( 'current' ) ;
116+ link . closest ( 'li.toctree-l2' ) . addClass ( 'current' ) ;
117+ link . closest ( 'li.toctree-l3' ) . addClass ( 'current' ) ;
118+ link . closest ( 'li.toctree-l4' ) . addClass ( 'current' ) ;
119+ }
118120 }
119121 catch ( err ) {
120122 console . log ( "Error expanding nav for anchor" , err ) ;
You can’t perform that action at this time.
0 commit comments