Keep nav-v2 focused on the active section#3354
Merged
Merged
Conversation
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>
marciw
reviewed
May 19, 2026
Member
marciw
left a comment
There was a problem hiding this comment.
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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.