Skip to content

Keep nav-v2 focused on the active section#3354

Merged
theletterf merged 4 commits into
nav-v2from
nav-v2-active-branch-accordion
May 19, 2026
Merged

Keep nav-v2 focused on the active section#3354
theletterf merged 4 commits into
nav-v2from
nav-v2-active-branch-accordion

Conversation

@theletterf
Copy link
Copy Markdown
Member

@theletterf theletterf commented May 19, 2026

Keep nav-v2 focused on the active section by collapsing folders that are outside the current page's branch. Without this, same-section HTMX navigation can leave stale folders expanded and make the sidebar look like multiple sections are active at once.

Demo: https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/3354/deploy-manage/distributed-architecture/clusters-nodes-shards/node-roles

Why

The nav-v2 prototype is meant to keep the current section focused, but once you open another branch it can stay expanded after navigating within the same section. That leaves the sidebar with multiple open branches and makes it harder to tell where the current page belongs.

What

This change recomputes folder expansion from the active page path and closes every folder that is not on that branch. It also uses the rendered folder hierarchy for manual accordion behavior, so opening one folder closes its siblings at the same level, and adds a focused frontend regression test for both behaviors.

Same-section navigation could leave stale folders expanded, which made the sidebar show multiple open branches. Recomputing expansion from the active page path keeps one relevant branch open and preserves accordion behavior when folders are opened manually.

Co-Authored-By: OpenAI GPT-5.4 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@theletterf theletterf added the bug label May 19, 2026
@theletterf theletterf requested a review from marciw May 19, 2026 14:20
Copy link
Copy Markdown
Member

@marciw marciw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's looking great!

Only thing I'm wondering about: if I click on something at the bottom of the nav, should the nav reposition / scroll up so that I can see the full selected section? will dm you a screen recording

theletterf and others added 3 commits May 19, 2026 19:03
Opening a lower section could still leave part of the active branch clipped below the sidebar viewport. Re-scrolling after the nav layout settles keeps the selected branch fully visible and locks in the behavior with a focused regression test.

Co-Authored-By: OpenAI GPT-5.4 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The Jump to page web component can alter the sidebar chrome after the active branch scroll is first calculated. Observing the sidebar chrome and scroll container makes the active branch scroll correction respond to those late layout changes.

Co-Authored-By: OpenAI GPT-5.4 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Prettier wrapped the ResizeObserver map type so the npm formatting check passes in CI.

Co-Authored-By: OpenAI GPT-5.4 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@theletterf theletterf marked this pull request as ready for review May 19, 2026 18:00
@theletterf theletterf requested a review from a team as a code owner May 19, 2026 18:00
@theletterf theletterf requested a review from Mpdreamz May 19, 2026 18:00
@theletterf theletterf merged commit 3e8c488 into nav-v2 May 19, 2026
20 of 21 checks passed
@theletterf theletterf deleted the nav-v2-active-branch-accordion branch May 19, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants