Skip to content

Make Expand all and Collapse all drive the API responses accordion - #4999

Merged
reakaleek merged 4 commits into
mainfrom
api-docs-responses-accord-9d7bc649
Nov 23, 2026
Merged

reakaleek merged 4 commits into
mainfrom
api-docs-responses-accord-9d7bc649

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

On API operation pages, Collapse all now closes every response. Expand all opens one response with all its fields. Hovering a response header greys the whole response.

Affects: API reference, Site UI

Prompt summary: Jan asks for the API docs responses to behave as a strict accordion. Only one response is open at a time, and clicking an open one closes it. Collapse all closes everything. Expand all opens only the first response, or the open one, with all its children. The hover state also moves from the header to the whole response, in the colour of the response body.

Why

The page's Expand all / Collapse all button skips responses. Collapse all leaves the open response open. Expand all opens the fields inside every response, including the closed ones, so a later click on a closed response shows fields that were opened behind the scenes. Hovering greys only the header row, in a colour that matches nothing else in the response.

What

Which disclosures the button acts on

Collapse all acts on every disclosure on the page, responses included. Expand all acts on a smaller set that leaves out every closed response except one target. The target is the open response, or else the one the page opens on load. The button label checks the smaller set, so it reads "Collapse all" once the target response and its fields are open.

The response the page opens on load

The server opens the response whose status sorts first, which can differ from spec order. _ResponsesBlock.cshtml marks that panel with data-api-response-default="true", so the client does not have to copy StatusSortKey. RazorSlices renders a null attribute value as an empty attribute here, so the marker uses explicit "true" and "false" values.

Hover

Hovering a response header greys the whole response, body included, in the open body's colour. The colour is one custom property, --response-body-bg, shared by the hover state, the open body and the expand toggle's label. Hovering only inside an open body does not grey it, because clicking there does not toggle the response. The navigation-preview layout gets the same hover in api-reference.css, using --color-surface-sunken, its own token for the open body.

Verify

mise run site:test
dotnet test --project tests/Elastic.ApiExplorer.Tests
mise run serve

On an operation with several responses, open a response other than the first and press Expand all. That response stays open with all its fields, and the others stay closed. Press Collapse all, then Expand all, and the first response opens.

Check on the preview

  • Cloud: Cancel pending plan: five responses. Open 400, press Expand all, and only 400 opens with its field. Hover a header to grey the whole response.
  • Elasticsearch: Search: one response with 42 nested fields. Expand all opens all of them, and Collapse all closes the response.

🤖 Generated with Claude Code

Collapse all now closes every response. Expand all opens one response
with all its fields: the open one, or the one the page opens on load.
Hovering a response header greys the whole response in the colour of
its open body.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 20, 2026 21:29
@reakaleek
reakaleek requested a review from technige November 20, 2026 21:29
reakaleek and others added 3 commits November 20, 2026 22:33
…by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

.response-summary:hover {
/* Hovering the header greys the whole response, in the colour of its open body. */
.response-panel:has(> .response-summary:hover) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

Add a browser test for the response hover state with NAVIGATION_PREVIEW enabled. The accordion tests only check clicks and expansion state, so they would pass if hovering the header still highlighted only the header, or if hovering the response body also highlighted the whole panel.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

@github-actions

Copy link
Copy Markdown
Contributor

@reakaleek
reakaleek merged commit 241bb48 into main Nov 23, 2026
44 checks passed
@reakaleek
reakaleek deleted the api-docs-responses-accord-9d7bc649 branch November 23, 2026 09:07
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.

2 participants