Add accordion navigation to documentation tree menu#3819
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the documentation tree navigation to use <details>/<summary> for collapsible branches, improves tree styling/interaction (auto-expanding on filter and auto-collapsing siblings), and adjusts breadcrumb generation to use relative permalinks.
Changes:
- Convert tree menu branches to
<details>/<summary>and add logic to detect “branch vs leaf”. - Add JS behavior to expand matching ancestors during filtering and collapse sibling branches on open.
- Refresh tree menu SCSS for sticky/scrollable layout, custom chevrons, and active styling; update breadcrumbs to build from
.RelPermalink.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/index.js | Expands/collapses <details> based on filter and click behavior (auto-collapse siblings). |
| src/css/components/_tree.scss | Restyles tree layout and <details>/<summary> presentation with custom markers and animations. |
| site/layouts/partials/tree.html | Renders tree branches with <details>/<summary> and adds directory inspection to decide branch/leaf. |
| site/layouts/partials/crumbs.html | Switches breadcrumb path building from .Permalink to .RelPermalink with Scratch state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {{ $.Scratch.Set "path" "/" }} | ||
| {{ range $index, $element := split .RelPermalink "/" }} | ||
| {{- if ne $element "" }} | ||
| {{- $.Scratch.Add "path" $element }} |
| } | ||
|
|
||
| @media (max-width: 850px) { | ||
| max-height: Min(30vh, 300px); |
| {{- $hasValidChildren := false }} | ||
| {{- $stat := os.Stat .path }} | ||
| {{- if $stat.IsDir }} | ||
| {{- range (readDir .path) }} | ||
| {{- if not (in .Name "image" | or (eq .Name "_index.md")) }} | ||
| {{- $hasValidChildren = true }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} |
| Array.from(menu.getElementsByTagName('details')).map(function(el) { | ||
| if (el.parentElement.classList.contains('tree-branch-active')) { | ||
| el.setAttribute('open', ''); | ||
| } else { | ||
| el.removeAttribute('open'); | ||
| } | ||
| }); |
| const ul = details.parentElement.parentElement; | ||
| if (ul) { | ||
| ul.querySelectorAll(':scope > li > details').forEach(sibling => { |
|
Great job! No new security vulnerabilities introduced in this pull requestUse @Checkmarx to interact with Checkmarx PR Assistant. |
Signed-off-by: aheteshamm <ahetesham964@gmail.com>

Summary
Fixes #2445
This PR converts the documentation tree menu into a collapsible accordion navigation structure to reduce visual clutter and improve usability.
Changes
Notes
I reviewed the discussion in #2707 and noticed some of the concerns raised around discoverability of expandable nodes, hover-based interactions, and navigation behavior. This implementation takes a different approach using visible expand/collapse indicators, click-based interaction, active page highlighting, automatic expansion of the current navigation path, and handling of empty sections.
Preview
https://zaproxy.vercel.app/docs/desktop/
Screenshots
Before
After
Additional View