@@ -110,9 +110,12 @@ function loadPage(target) {
110110 updateHistory ( match ) ;
111111 return ;
112112 }
113- replaceArticle ( href , newDoc )
113+ replaceArticle ( href , newDoc ) ;
114114 scrollToFragment ( ) ;
115115 initArticle ( href ) ;
116+ if ( window . setupDocSearch ) {
117+ window . setupDocSearch ( getSelectedVersion ( ) ) ;
118+ }
116119 return true ;
117120 } )
118121 . catch ( error => {
@@ -538,9 +541,10 @@ function handleDocumentChange(event) {
538541 const currentPath = window . location . pathname ;
539542 //const versionedPath = target.dataset.path;
540543
541- window . setupDocSearch ( selectedVersion ) ; // TODO: Only if on versioned page?
542-
543544 localStorage . setItem ( 'docs-version' , selectedVersion ) ; // TODO: handle multiple
545+ if ( window . setupDocSearch ) {
546+ window . setupDocSearch ( selectedVersion ) ;
547+ }
544548 target . closest ( ".nav-section" ) . querySelectorAll ( ":scope > .nav-ol" ) . forEach (
545549 el => {
546550 if ( el . dataset . version == selectedVersion ) {
@@ -684,11 +688,8 @@ window.onload = () => {
684688
685689 loadPage ( window . location . href )
686690
687- window . setupDocSearch ( currentVersion ?? stableVersion ) ;
688-
689691 // Add central click handler to document
690692 document . addEventListener ( "click" , handleDocumentClick ) ;
691-
692693 document . addEventListener ( "change" , handleDocumentChange ) ;
693694
694695 var isMobile = window . innerWidth <= 768 ;
0 commit comments