Skip to content

Drop the wrapper and layout classes from sidebar folder toggles - #4955

Open
akira28 wants to merge 4 commits into
mainfrom
feature/sidebar-folder-toggle
Open

akira28 wants to merge 4 commits into
mainfrom
feature/sidebar-folder-toggle

Conversation

@akira28

@akira28 akira28 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Folder and heading rows in the sidebar no longer repeat their layout classes, and their toggle loses a wrapper element. The API sidebar is another 3–4% smaller, and it looks and behaves the same.

Affects: Site UI, API reference

Stack: 2 of 4, on top of #4953, under #4956.

Prompt summary: Stack the third sidebar markup step on top of #4953: a lighter folder toggle. The three PRs come from the sidebar analysis for elastic/docs-eng-team#1183, which is about bringing API pages under Googlebot's 2 MB HTML limit.

Why

Folder rows take about 500 bytes each, and the Kibana API sidebar has 72 of them on every page. Each title row repeated peer grid grid-cols-[1fr_auto] w-full. Each toggle repeated group/label flex mr-2 items-start on its label and wrapped its chevron in a div.nav-toggle-btn.

What

The title row keeps only peer

pages-nav.ts and the CSS that opens a subtree both find the row through peer, so it stays. A rule in Tailwind's utilities layer, at no specificity, applies the grid the classes set.

The label is the button

The chevron now sits directly in the label. The label fills the row height, as it did with the old classes, so on a title that wraps to two lines a click below the chevron still toggles the folder. The chevron takes the padding, rounding and hover background the .nav-toggle-btn wrapper had, so the button box stays 22×22 at the top of the row.

The open chevron follows the label's checkbox

The chevron's open rotation keyed on the group/label class. It now keys on .nav-folder > .peer > label:has(:checked).

Nothing that the expand and collapse logic reads changes. That logic is pages-nav.ts and NavigationCurrentMarker, and it reads the checkbox, .peer, li.nav-folder and .nav-subtree-clip. Island rows, which link out with a double chevron and have no checkbox, keep their markup.

Results

An isolated build of docs/:

main #4953 This PR
Kibana sidebar (operation-osquerydeletepacks) 279 KB 189.6 KB 181.8 KB
Elasticsearch sidebar (operation-reindex) 217 KB 155.6 KB 150.4 KB
All API HTML (7,243 pages) 2.56 GB 2.074 GB 2.032 GB
API pages over 2 MB 71 68 68

This is less than the analysis estimated (18 KB per Kibana sidebar). That estimate replaced the whole toggle with one checkbox, which would change how it is clicked and styled.

Compared with #4953's build:

  • Sidebar screenshots: pixel-identical on the Kibana and Elasticsearch pages above and on /syntax/tabs. This covers desktop and tablet size, with folders as loaded and with every folder open.
  • Hovered toggle: pixel-identical. With the label's hover rule removed, the same comparison finds 482 differing pixels, so it does catch a missing hover style.
  • Clicking a toggle: behaves the same on both builds. The checkbox checks, the subtree shows, and the chevron turns from -90° to 0°.

Out of scope: the NAVIGATION_PREVIEW styles in pages-nav-figma.css. They key on .peer, .nav-chevron and the checkbox, which this PR keeps, but I did not screenshot that flag.

Verify

dotnet test --project tests/Navigation.Tests
# LegacyHeadingRow_RendersTitleWithoutAnEmptyLink, LegacyGroupRow_RendersALabelOverItsItemsWithNoToggle (snapshots of the lighter folder row)
mise run site:test

Check on the preview

  • Kibana: Delete packs: the current folder is open with its chevron pointing down. Click a closed folder's chevron and the folder opens. Hover a chevron and it gets a grey background.
  • Upgrade: a Markdown page's sidebar folders open, close and look the same as on production.

🤖 Generated with Claude Code

@akira28
akira28 requested a review from a team as a code owner November 19, 2026 11:54
@akira28
akira28 requested a review from Mpdreamz November 19, 2026 11:54
@akira28
akira28 added this pull request to stack #4954 November 19, 2026 11:55
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4955/

@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from a507da9 to 1dedaa1 Compare November 24, 2026 08:21
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 1dedaa1 to cff0079 Compare November 24, 2026 12:15
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from cff0079 to a369c79 Compare November 30, 2026 11:37
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from a369c79 to 6bc3c8b Compare November 30, 2026 12:01
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 6bc3c8b to 284d00f Compare November 30, 2026 12:15
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 284d00f to 7939c2f Compare November 30, 2026 12:22
Base automatically changed from feature/sidebar-method-badge to main November 30, 2026 12:48
akira28 and others added 4 commits November 30, 2026 13:48
Each folder and heading row in the legacy sidebar repeated
`peer grid grid-cols-[1fr_auto] w-full` on its title row, and
`group/label flex mr-2 items-start` plus a `nav-toggle-btn` div around
the chevron in its toggle. The row keeps `peer`, the label becomes the
button, and `styles.css` sets the grid, the label's place, its button
look and the open chevron's rotation. Island rows keep their markup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With self-start, a wrapped folder title left the area below the chevron
unclickable. The label fills the row as it did with the old wrapper, and
the chevron carries the padded hover box the inner div used to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
docs-preview — 92e139e3 Deployed Nov 30, 2026 by github-actions[bot]
assembler-preview — 92e139e3 Deployed Nov 30, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant