Skip to content

Let API union variants fold their fields behind a toggle - #4491

Merged
akira28 merged 1 commit into
mainfrom
api-explorer-union-collapsed
Oct 16, 2026
Merged

akira28 merged 1 commit into
mainfrom
api-explorer-union-collapsed

Conversation

@akira28

@akira28 akira28 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Variants of a oneOf/anyOf behind chips now have a "hide properties" toggle, the same one object rows use, so a reader can shorten the view.

Affects: API reference

Prompt summary: Fix elastic/docs-eng-team#1074. Objects fold their fields but oneOf/anyOf blocks do not, and nothing says how to collapse them. Add a way to collapse them and keep the default as it is.

Why

Two or more variants show behind chips, and the picked variant lists its fields at once. Those fields have no toggle, so a long variant cannot be folded. Object rows next to it fold with "hide properties".

What

Toggle on chip variants

A variant behind chips renders the same "hide properties" toggle as a lone variant or an object row. The existing disclosure script handles the click, and links or find-in-page into a folded variant still open it.

Default stays expanded

The variant starts expanded, as before: picking a chip is the choice to read that variant. Only the control to fold it is new.

Verify

dotnet test tests/Elastic.ApiExplorer.Tests/
# Render_ThreeVariants_ShowsTheFieldsAtOnceWithAToggleAndWithoutRepeatingTheName

Check on the preview

  • Kibana: Create a case — open the type variants and click "hide properties" under a chip; the fields fold and "show properties" brings them back.
  • Kibana: Create output — a long variant (35 fields) folds to a short view.

Variants behind chips showed their fields with no way to collapse them, while object rows fold. The fields still start expanded; a "hide properties" toggle now shortens the view.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@akira28
akira28 requested a review from a team as a code owner October 16, 2026 11:38
@akira28
akira28 requested a review from theletterf October 16, 2026 11:38
@akira28
akira28 merged commit 8f03477 into main Oct 16, 2026
40 of 41 checks passed
@akira28
akira28 deleted the api-explorer-union-collapsed branch October 16, 2026 11:45
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