Skip to content

Add quick links to the sections of an operation page - #4641

Open
akira28 wants to merge 8 commits into
feature/api-explorer-expand-collapsiblefrom
feature/api-explorer-section-links
Open

akira28 wants to merge 8 commits into
feature/api-explorer-expand-collapsiblefrom
feature/api-explorer-section-links

Conversation

@akira28

@akira28 akira28 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Operation pages now have a sticky bar of quick links to their sections: Authorization, Path, Query, Header, Body and Response. A click jumps to the section, and the link of the section in view is underlined. The examples rail also stays in view while the sections scroll.

Affects: API reference

Stack: 2 of 2, on top of #4636

Prompt summary: Stack a second PR on the expand-by-default change that adds fast links to the response, path and query sections. It follows the epTabs bar of the endpoint page proposal in the API docs prototype, in the current stylesheet and not the flagged design system.

Why

With every section open, an operation page gets long. A reader looking for the query parameters or the response scrolls past everything above it, and the page offers no map of what it holds.

What

The bar

_SectionLinks.cshtml renders one link per section the operation has, in page order. OperationViewModel.SectionLinks builds the list, and the bar is left out when the page has fewer than two sections.

Behaviour

The bar sticks under the page header and scrolls sideways on a narrow window. A link is a plain #anchor, so the existing hash handling opens a folded section it points into, and the section stops below the bar instead of under it.

Sticky examples rail

From 1024px up, .api-page-rail is sticky under the page header. When the examples are taller than the window, they scroll inside the rail under Copy page, so the code blocks keep their fixed line caps from #4554 and the Copy page menu is not clipped. That PR made the rail normal page flow because a rail sized to fit the window shrank the request code; this one keeps the caps and lets the rail scroll instead. Below 1024px the rail still follows the article.

Reused pieces

The scroll-spy is initToc from ds/toc.ts, the one behind the "On this page" outline: the bar carries data-toc and data-toc-link, and initOperationView calls initToc. The bar adds no script and one small block of CSS in api-docs.css. The design-system stylesheet has no styles for the bar yet, so a page built with NAVIGATION_PREVIEW on leaves it out and renders as before.

Out of scope: The bar for the flagged design system, marking the last link at the bottom of a short page (the outline spy does not), and the filter and sort controls the prototype shows in the query and body sections.

Verify

dotnet test tests/Elastic.ApiExplorer.Tests
cd src/Elastic.Documentation.Site && npm run test

Check on the preview

  • Elasticsearch: Search — the bar lists Authorization, Path, Query, Body and Response; scroll and watch the underline follow, then click Response.
  • Elasticsearch: Delete async search — a short page: every link is visible, and the underline follows the section you scroll to.
  • Same page, scroll far down — the examples rail stays beside the sections; on a short window the examples scroll under Copy page.
  • Elasticsearch API landing page — control: no bar, unchanged.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

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

Sample changed pages:

akira28 and others added 8 commits November 4, 2026 08:58
A sticky bar above the sections links to Authorization, Path, Query,
Header, Body and Response, and underlines the section in view. It
follows the endpoint page proposal.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The bar now binds to the existing initToc scroll-spy and the example
chip count pill instead of its own copies. Sections reached from the
bar also stop below it, not under it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A short last section never reaches the activation line, so the outline
spy now marks the last heading within a few pixels of the page bottom.
A spy also stops listening once its outline leaves the page, so htmx
swaps no longer pile up scroll handlers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The new bottom-of-page rule made jsdom's zero-height page count as
scrolled to the end, so the test marked the last link.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
With every section open, operation pages are long and the examples
scrolled away after the first screen. The rail is sticky again from
1024px up and scrolls inside itself when the examples are taller than
the window, so the code blocks keep their fixed line caps.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The rail's own scrolling clipped the Copy page menu, which opens past
the rail's left edge. The rail no longer clips; the examples below the
button shrink to the window and scroll.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Only the parameter and response links had a number, and a count of one
was hidden. Each link now shows what its section lists: privileges,
parameters, body fields or variants, or responses. The numbers reuse the
name lists the section headers already summarise.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The links are plain labels again, which keeps the bar short and avoids
numbers that count different things in each section.

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

This branch was successfully deployed

2 active deployments
docs-preview — b33b7de7 Deployed Nov 4, 2026 by github-actions[bot]
assembler-preview — b33b7de7 Deployed Nov 4, 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