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) {
343
343
onNavigate ( source ) {
344
344
const { auto2top, topMargin } = this . config ;
345
345
const { path, query } = this . route ;
346
-
347
- this . #markSidebarActiveElm( ) ;
346
+ const activeSidebarElm = this . #markSidebarActiveElm( ) ;
348
347
349
348
// Note: Scroll position set by browser on forward/back (i.e. "history")
350
349
if ( source !== 'history' ) {
@@ -371,13 +370,20 @@ export function Events(Base) {
371
370
}
372
371
}
373
372
373
+ const isNavigate = source === 'navigate' ;
374
+ const hasId = 'id' in query ;
375
+ const noSubSidebar = ! activeSidebarElm ?. querySelector ( '.app-sub-sidebar' ) ;
376
+
374
377
// 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 ) ;
377
383
}
378
384
379
385
// Clicked anchor link or page load with anchor ID
380
- if ( query . id || source === 'navigate' ) {
386
+ if ( hasId || isNavigate ) {
381
387
this . #focusContent( ) ;
382
388
}
383
389
}
You can’t perform that action at this time.
0 commit comments