File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -392,16 +392,18 @@ export default async function decorate(block) {
392392 const openedPaths = getOpenedPaths ( ) ;
393393
394394 openedPaths . forEach ( pathname => {
395- const anchor = Array . from ( navigationLinksUl . querySelectorAll ( "a" ) )
396- . find ( a => a . href && a . getAttribute ( "href" ) === pathname ) ;
395+ // Find ALL anchors with this href (multiple items can have the same href)
396+ const anchors = Array . from ( navigationLinksUl . querySelectorAll ( "a" ) )
397+ . filter ( a => a . href && a . getAttribute ( "href" ) === pathname ) ;
397398
398- if ( anchor ) {
399+ // Expand all matching items
400+ anchors . forEach ( anchor => {
399401 const li = anchor . closest ( "li" ) ;
400402 const childUl = li ?. querySelector ( "ul" ) ;
401403 if ( li && childUl ) {
402404 toggleNavItem ( li , true , childUl , anchor ) ;
403405 }
404- }
406+ } ) ;
405407 } ) ;
406408 }
407409
@@ -412,11 +414,11 @@ export default async function decorate(block) {
412414 sessionStorage . setItem ( 'sidenavScrollPos' , sideNav . scrollTop ) ;
413415 } ) ;
414416
417+ // Store scroll restoration function for later use
415418 const savedPos = sessionStorage . getItem ( 'sidenavScrollPos' ) ;
416419 if ( savedPos !== null ) {
417- // Delay scroll restoration to ensure DOM is fully rendered
418- setTimeout ( ( ) => {
420+ window . restoreSideNavScroll = ( ) => {
419421 sideNav . scrollTop = parseInt ( savedPos , 10 ) ;
420- } , 100 ) ;
422+ } ;
421423 }
422424}
Original file line number Diff line number Diff line change @@ -561,7 +561,7 @@ function activeSubNav(actTab) {
561561 const sidenavItems = navLinksUl ?. querySelectorAll ( ':scope > ul li' ) || [ ] ;
562562 const topNavPath = actTab . pathname ;
563563 const pagePath = window . location . pathname ;
564-
564+
565565 sidenavItems . forEach ( li => {
566566 // Handle header labels - check the next sibling's link
567567 if ( li . classList . contains ( 'nav-header-label' ) ) {
@@ -616,6 +616,11 @@ function activeSubNav(actTab) {
616616 // Make side nav visible after all updates are complete
617617 if ( sidecontainer ) {
618618 sidecontainer . style . visibility = "visible" ;
619+
620+ // Restore scroll position after side nav is visible and filtering is complete
621+ if ( window . restoreSideNavScroll ) {
622+ window . restoreSideNavScroll ( ) ;
623+ }
619624 }
620625}
621626
You can’t perform that action at this time.
0 commit comments