File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -343,8 +343,7 @@ export function Events(Base) {
343343 onNavigate ( source ) {
344344 const { auto2top, topMargin } = this . config ;
345345 const { path, query } = this . route ;
346-
347- this . #markSidebarActiveElm( ) ;
346+ const activeSidebarElm = this . #markSidebarActiveElm( ) ;
348347
349348 // Note: Scroll position set by browser on forward/back (i.e. "history")
350349 if ( source !== 'history' ) {
@@ -371,13 +370,20 @@ export function Events(Base) {
371370 }
372371 }
373372
373+ const isNavigate = source === 'navigate' ;
374+ const hasId = 'id' in query ;
375+ const noSubSidebar = ! activeSidebarElm ?. querySelector ( '.app-sub-sidebar' ) ;
376+
374377 // Clicked anchor link
375- if ( path === '/' || ( query . id && source === 'navigate' ) ) {
376- isMobile ( ) && this . #toggleSidebar( false ) ;
378+ const shouldCloseSidebar =
379+ path === '/' || ( isNavigate && ( hasId || noSubSidebar ) ) ;
380+
381+ if ( shouldCloseSidebar && isMobile ( ) ) {
382+ this . #toggleSidebar( false ) ;
377383 }
378384
379385 // Clicked anchor link or page load with anchor ID
380- if ( query . id || source === 'navigate' ) {
386+ if ( hasId || isNavigate ) {
381387 this . #focusContent( ) ;
382388 }
383389 }
You can’t perform that action at this time.
0 commit comments