Skip to content

Add accordion navigation to documentation tree menu#3819

Open
aheteshamm wants to merge 1 commit into
zaproxy:mainfrom
aheteshamm:main
Open

Add accordion navigation to documentation tree menu#3819
aheteshamm wants to merge 1 commit into
zaproxy:mainfrom
aheteshamm:main

Conversation

@aheteshamm
Copy link
Copy Markdown

Summary

Fixes #2445

This PR converts the documentation tree menu into a collapsible accordion navigation structure to reduce visual clutter and improve usability.

Changes

  • Converted the documentation tree into collapsible accordion sections.
  • Added active page highlighting so users can easily identify their current location.
  • Automatically expands the active navigation path on page load.
  • Automatically collapses sibling sections when opening a new section to reduce clutter.
  • Added rotating chevrons for expanded/collapsed states.
  • Improved spacing and hierarchy for nested items.
  • Added sticky sidebar navigation for long documentation pages.
  • Added handling for empty sections to avoid rendering unnecessary accordion controls.
  • Fixed a breadcrumb rendering issue encountered during local development.

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

image

After

image

Additional View

image

Copilot AI review requested due to automatic review settings June 1, 2026 13:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +2 to +5
{{ $.Scratch.Set "path" "/" }}
{{ range $index, $element := split .RelPermalink "/" }}
{{- if ne $element "" }}
{{- $.Scratch.Add "path" $element }}
}

@media (max-width: 850px) {
max-height: Min(30vh, 300px);
Comment on lines +23 to +31
{{- $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 }}
Comment thread src/index.js
Comment on lines +147 to +153
Array.from(menu.getElementsByTagName('details')).map(function(el) {
if (el.parentElement.classList.contains('tree-branch-active')) {
el.setAttribute('open', '');
} else {
el.removeAttribute('open');
}
});
Comment thread src/index.js
Comment on lines +252 to +254
const ul = details.parentElement.parentElement;
if (ul) {
ul.querySelectorAll(':scope > li > details').forEach(sibling => {
@psiinon
Copy link
Copy Markdown
Member

psiinon commented Jun 1, 2026

Logo
Checkmarx One – Scan Summary & Detailsc81fd0d9-3984-474a-af17-daf100c123c9

Great job! No new security vulnerabilities introduced in this pull request


Use @Checkmarx to interact with Checkmarx PR Assistant.
Examples:
@Checkmarx how are you able to help me?
@Checkmarx rescan this PR

Signed-off-by: aheteshamm <ahetesham964@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add accordions to docs menu

3 participants