Skip to content

feat(Collapsible): let the chevron lead the trigger - #5993

Merged
cixzhang merged 12 commits into
mainfrom
core-collapsible-chevron-placement
Sep 8, 2026
Merged

cixzhang merged 12 commits into
mainfrom
core-collapsible-chevron-placement

Conversation

@ernestt

@ernestt ernestt commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What

Collapsible and CollapsibleGroup take a chevronPlacement prop. The default, 'end', is exactly what ships today; 'start' moves the disclosure arrow ahead of the label.

The leading arrow is the tree and file-browser convention — the one you want when a column of labels should line up behind the arrows. Until now only TreeList and the Table row-expansion column could draw one, so a card or accordion header had no way to match them.

leading chevron, light

leading chevron, dark

Why the glyph changes with the side

A trailing chevron points down and flips up. A leading one points into the row and turns down. Rotating chevronDown a quarter turn would leave the closed state pointing the wrong way, so 'start' swaps in chevronRight and rotates 0° → 90°, mirrored in RTL. That is what TreeList already does, so the two now agree.

Why the group carries it

A list whose arrows change sides row to row reads as a bug, so CollapsibleGroup passes the placement down through the same presentation context that already carries hasDividers and density. An individual item still overrides its group, and a collapsible nested inside an item's body keeps its own default rather than inheriting.

One layout consequence

A leading arrow also makes the trigger label fill the row. The trigger is space-between: with a trailing arrow that rule is what separates the two, but with the arrow leading there is no third child to absorb the free space, so an unfilled label would be thrown to the opposite edge with a gap behind the arrow. Filling it also gives a trigger that spreads its own contents (hAlign="between" and the like) the whole row to spread across — which is what the screenshots above rely on.

This overlaps with #5933, which makes the label fill unconditionally. The two are independent and either order merges; if #5933 lands first, the conditional style here becomes redundant and the rebase drops it.

Test plan

  • 43 Collapsible tests pass, 7 of them new: DOM order for each side, that the glyph changes with the side rather than only the position, group inheritance, item-over-group override, no leak into a nested collapsible, and that the label fills the row when the arrow leads.
  • tsc --noEmit and eslint clean on packages/core/src/Collapsible.
  • Screenshots above are the table-grouped template with chevronPlacement="start" applied locally, light and dark.

Collapsible has always drawn its chevron as a trailing indicator. The
leading disclosure arrow — the tree and file-browser convention, where the
labels form a column the arrows sit in front of — was only available from
TreeList and the Table row-expansion column, so a card or accordion header
had no way to match them.

`chevronPlacement` adds that side. The default is unchanged.

The side picks the glyph as well as the order. A trailing chevron points
down and flips up; a leading one points into the row and turns down, so
`start` swaps chevronDown for chevronRight and rotates a quarter turn
rather than a half, mirrored in RTL the way TreeList already does it.

CollapsibleGroup carries it through the presentation context that already
holds hasDividers and density, because a list whose arrows change sides
row to row reads as a bug. An item still overrides its group, and a
collapsible nested in an item's body keeps its own default.

A leading arrow also makes the label fill the row: the trigger is
space-between, so with nothing after the label to absorb the free space it
would otherwise be thrown to the far edge, leaving a gap behind the arrow.

Co-authored-by: Cursor <[email protected]>
@vercel

vercel Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 8, 2026 3:36am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 3, 2026
@github-actions github-actions Bot added the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Sep 3, 2026
github-actions Bot added a commit that referenced this pull request Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Collapsible (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 466 -
Complexity N/A Very High (49) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

2 of 2 shot(s) changed. View the report

A repository maintainer can accept these exact frames: /accept-visual 34183876887/1 <why every changed frame is correct>

A change here is a question, not a failure: check whether the after is the
picture you intended. If it is, say so in the PR — the release gate's baseline
is updated deliberately, and this check never rewrites it.

component story theme mode pixels
Collapsible Single Mode — Leading Chevron neutral light 3,531
Collapsible Single Mode — Leading Chevron neutral dark 3,446
Collapsible — Single Mode — Leading Chevron — neutral light
BeforeAfterDiff
Before visual regression frame After visual regression frame Pixel difference frame
Collapsible — Single Mode — Leading Chevron — neutral dark
BeforeAfterDiff
Before visual regression frame After visual regression frame Pixel difference frame

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Sep 4, 2026
github-actions Bot added a commit that referenced this pull request Sep 4, 2026
chevronPlacement gains 'none': no chevron, and the trigger content is the
whole button. For a trigger that already reads as openable — a category icon
that becomes an arrow under the pointer, a caret drawn into a graphic — where
the built-in chevron is a second affordance saying the same thing.

The chevron was unconditional, and StyleX has no child selectors, so there was
no reaching it from outside. The only way out was to stop using Collapsible and
hand-roll the aria-expanded/aria-controls pair, which is the wiring most worth
not hand-rolling. Semantics are untouched: still a button, still aria-expanded.

One prop rather than a side plus a hasChevron boolean, because a side and 'no
chevron' cannot both be true and two props would let a caller say so.

Also drops the changeset from minor to patch: [feat] bumps patch while 0.x,
which check:changesets enforces and this changeset was failing.

Co-authored-by: Cursor <[email protected]>
Resolve the RTL audit exemption list: keep main's newer entries and
drop core/Collapsible, which this branch removes now that the leading
chevron is exercised by a real RTL story.
Resolve apps/storybook/rtl-audit/verified-not-applicable.json: main added
Banner, ThreeD, Button and IconButton entries; this branch retires the
core/Collapsible exemption because the leading-chevron work adds real RTL
coverage for it. Keep main's list, minus core/Collapsible.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, the leading-chevron behavior is almost there. The current Collapsible contract limits this to chevronPosition?: 'start' | 'end'; this head instead exports chevronPlacement with none, which lets callers remove Collapsible’s visible disclosure affordance. Please rename the prop/type across Collapsible and CollapsibleGroup to chevronPosition / CollapsibleChevronPosition, remove none and its docs/tests/changeset text, and keep the existing start/end behavior.

[Reviewed by Robohands]

@cixzhang

cixzhang commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

/accept-visual 34183876887/1 The leading chevrons match the current Collapsible contract: start precedes the label, mirrors inward in RTL, and points down when expanded; end remains the unchanged default.

github-actions Bot added a commit that referenced this pull request Sep 8, 2026
@github-actions github-actions Bot added the visual-approved Current visual bundle has an explicit acceptance record label Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Visual changes accepted for a23c765f9f69. A new push invalidates this approval; after merge, the reviewed AFTER frames must reproduce before the baseline is promoted.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks—the earlier chevronPlacement/none block is resolved. chevronPosition, the exported type, precedence, RTL behavior, and full-row labels now match the current Collapsible contract.

[Reviewed by Robohands]

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Sep 8, 2026
@cixzhang
cixzhang merged commit 4092486 into main Sep 8, 2026
30 checks passed
github-actions Bot added a commit that referenced this pull request Sep 8, 2026
@github-actions
github-actions Bot deleted the core-collapsible-chevron-placement branch September 8, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — a23c765f Deployed Sep 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. visual-approved Current visual bundle has an explicit acceptance record

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants