Skip to content

Commit 2889d66

Browse files
theletterfcodexcursoragent
committed
Limit root nav auto-expansion
Only auto-open a section root sidebar when it has a single top-level folder, avoiding the fully expanded Reference nav while preserving single-TOC sections. Co-Authored-By: GPT-5.5 <noreply@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 5e93607 commit 2889d66

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/Elastic.Documentation.Site/Assets/pages-nav-v2.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,13 +616,12 @@ function expandToCurrentPageForPath(nav: HTMLElement, pathnameRaw: string) {
616616
*/
617617
function expandToCurrentPage(nav: HTMLElement) {
618618
if (isOnSectionRootPage(nav)) {
619-
// On the section root page, expand all top-level folders so the
620-
// section content is visible even though no specific page is current.
621-
nav.querySelectorAll<HTMLInputElement>(
619+
const topLevelFolders = nav.querySelectorAll<HTMLInputElement>(
622620
'#nav-tree > li > .peer > input[type="checkbox"]'
623-
).forEach((cb) => {
624-
cb.checked = true
625-
})
621+
)
622+
if (topLevelFolders.length === 1) {
623+
topLevelFolders[0].checked = true
624+
}
626625
return
627626
}
628627
expandToCurrentPageForPath(nav, window.location.pathname)

0 commit comments

Comments
 (0)