Repository navigation
Show API sidebar groups as static labels and fix its scrollbar - #4928
Conversation
The API sidebar folded Topics and Types behind a toggle, listed the tags with no label, and drew a rule between the blocks. Readers could not tell where one group ended and the next began. Each group is now an uppercase label over rows that are always open, with the same type as the spec switcher. The rules between blocks are gone. Specs with `x-tagGroups` keep their own group headings. The shared `.nav-chevron` no longer strokes its filled symbols, so carets are thin in every sidebar. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4928/ |
The switcher and search sat inside the sidebar's scroll container and stayed in place with `position: sticky`, so the scrollbar ran the full height beside them. The switcher is now a fixed block at the top of the sidebar, and only the tree scrolls in its own `.sidebar-nav-scroll` wrapper, so the scrollbar starts under the switcher's border. `getNavScrollContainer` finds the new scroller, so scrolling the current page into view and keeping the scroll position across tree swaps work as before. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…a50e0046 # Conflicts: # src/Elastic.Documentation.Site/Assets/api-docs.css
| <div class="sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto simple-scrollbar [scrollbar-gutter:stable]"> | ||
| @(new HtmlString(Model.NavigationHtml)) | ||
| </div> |
There was a problem hiding this comment.
Severity: P3 (Low)
Add a browser-level regression test for the new API scrollport. The updated rendering snapshots use a literal <nav>tree</nav>, so they cannot verify that a long tree scrolls within the available height while the identity/filter remain fixed. Cover reaching the final rows and preserving the inner scroll position across a same-tree HTMX navigation; these are the behaviors changed here, but neither is exercised by the snapshot updates.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
Partly fixed in 563d6b5. Two tests in pages-nav.test.ts now use the API markup, with the switcher outside a .sidebar-nav-scroll wrapper. One checks that the tree's scroll position survives a same-tree swap. The other checks that the current row scrolls into view inside the tree while the nav stays at zero. Both fail if getNavScrollContainer stops matching the wrapper.
The layout half is not covered, and I would rather say so than imply it is. jsdom has no layout. The journeys can scroll and read get box, but they have no assertion on a scroll offset, and Synthetics journeys compare no transcripts. The visual/ suite is local and takes its baselines from main. I checked that a long tree scrolls within the height while the switcher stays put, and that the last rows are reachable, by hand in a real browser, on desktop and in the mobile drawer. A CI check for that needs a Playwright layout test, which I have not added here.
A review of this branch pointed out that specs with `x-tagGroups` gained an automatic rule under the overview link. The rule exists only to sit under a root row, and the API product switcher already leads to the overview. The API landing now carries `ISidebarWithoutRootIndexNavigationItem`, so `NavigationRenderModel.CreateRootIndex` returns no row for it. With no row there is nothing for a rule to sit under, so the `Group`-first clause on the divider check is gone and `TreeHasSeparator` is back to what it was. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A review of this branch asked for coverage of the new API scrollport. Two tests now use the API markup, with the switcher outside a `.sidebar-nav-scroll` wrapper. One checks that the tree's scroll position survives a same-tree swap. The other checks that the current row scrolls into view inside the tree while the nav itself stays at zero. Both fail if `getNavScrollContainer` stops matching `.sidebar-nav-scroll`. Layout in a real browser is not covered, because jsdom has no layout and the journeys cannot assert a scroll offset. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The API sidebar now shows Topics, Operations and Types as uppercase labels over rows that stay open, in place of folded headings and rules between blocks. Carets are thinner in every sidebar, and the scrollbar no longer runs beside the switcher.
Affects:
Site UI,API referencePrompt summary: Make Topics and Types in the API sidebar plain, non-clickable group headers instead of dropdowns, add an Operations header, and drop the odd horizontal bars. Match the spec switcher's uppercase labels, keep the look of the regular docs navigation, and take the spacing from well-regarded API sidebars such as Vercel's. Keep the switcher out of the scrolling area, so the scrollbar does not run beside it.
Why
The API sidebar folded Topics and Types behind a toggle, listed the tags with no label, and drew a rule between the blocks. Readers could not tell where one group ended and the next began. The caret was also heavy:
.nav-chevronset a 1.5px stroke on symbols that are already filled hairline paths. The switcher stayed in place withposition: stickyinside the sidebar's scroll container, so the scrollbar ran the full height beside it.What
Groups are labels, not folders
Topics, Operations and Types render as a small uppercase label over their rows. The label has no link, toggle or chevron, and the rows are always visible. A new
Grouprender kind carries this, so docslabel:nodes andx-tagGroupsheadings keep their current look. Specs withx-tagGroupsget no Operations label, because those headings already group the operations.One rhythm for rows and labels
A label takes one row slot: it sits one row pitch above its first row, and groups are one and a half pitches apart. Rows keep the docs sidebar's semibold weight and 24px spacing at the top level. The label uses the same type as the spec switcher's
.api-menu-group-label.Dividers and the overview row are gone
The API navigation no longer builds separator items. The "Api Overview" row at the top is gone too, because the product switcher already leads to the overview. The API landing carries
ISidebarWithoutRootIndexNavigationItem, soCreateRootIndexreturns no row for it, and with no row there is no automatic rule either. Assembled builds already had no such row. TheSeparatorrender kind stays for the design-system sidebar samples.Thinner carets everywhere
.nav-chevronno longer strokes its symbols. Every chevron symbol is a filled path, so the docs sidebar carets thin out too, and the legacy sidebar now matches the v2 sidebar, which already setstroke: none.The switcher stays out of the scrolling tree
The switcher and search are now a fixed block at the top of the sidebar, and only the tree scrolls, in its own
.sidebar-nav-scrollwrapper. The scrollbar starts under the switcher's border.getNavScrollContainerinpages-nav.tsalso matches the new wrapper, so scrolling the current page into view and keeping the scroll position across tree swaps work as before.Verify
On a machine with a comma decimal locale,
mise run testreports 9 failures in theDeployingtests. They come from the locale and do not touch this change.Check on the preview
TOPICSandOPERATIONSlabels over open rows, the current page still highlighted and expanded.TYPESis the last label. There is no "Api Overview" row and no rule under the switcher.Out of scope: The v2 sidebar (
_TocTreeNav.cshtml) gets the label markup and style, with render snapshots but no browser check. The current-page highlight stays blue text and does not become a pill.