Repository navigation
fix(Collapsible): refresh block examples - #5567
Conversation
The content area was `display: none` when collapsed, which has nothing to interpolate — so the panel snapped open and shut, alone among the system's disclosure surfaces (ChatToolCalls already animates its group with a grid track, Layer and Dialog have entry animations). Put the content on an animatable track instead: - `interpolate-size: allow-keywords` makes `height: 0 -> auto` a real transition, so the panel interpolates to exactly its content height with nothing measured in JS. Browsers without it snap open, which is the behaviour this component had before — the degradation path is the status quo, not a regression. - `visibility: hidden` replaces `display: none` for the collapsed state. It keeps the subtree out of the a11y tree and the tab order, and its special interpolation rule keeps the subtree painted for the whole duration of a close, so the panel does not blank on the first frame. - The padding moves to an inner wrapper. Padding on a zero-height box still paints, so leaving it on the track kept a few pixels of gap when collapsed. - That inner wrapper also carries a fade. Height alone reads as a clip: the text is fully opaque from the first frame and the panel edge wipes down over it. Opening holds the content back for a beat of height and then fades it in over 4px, so it arrives into space that already exists; closing takes the content out first and lets the box finish on its own, so text is never squashed against a shrinking edge. Durations and easings read from private custom properties with the existing motion tokens as defaults, following the `--_tab-indicator-bottom` precedent in Tab.tsx, so a theme can retune the feel without reaching into the component. Test plan: - 70/70 Collapsible + CollapsibleGroup tests pass. One assertion changed: it named `display: none` directly, and now asserts the track's height and visibility. - Measured on the docsite examples (44px panel): height runs 0 -> 44px over 300ms; content holds at opacity 0 for 95ms, then fades in over 125ms. Closing clears the content by ~90ms with the box finishing at ~268ms. - `prefers-reduced-motion: reduce` settles in 23ms. - Card and Section, which compose Collapsible, still pass.
The six Collapsible blocks are what agents and readers copy from, and
they were teaching three things we do not want copied.
Type. Every example used the trigger's default `large` type (17px
semibold). That is right when a Collapsible is the heading of its own
surface — one per Card, one per Section — and wrong for a list of peers,
where every row claims heading weight and none reads as more important
than the next. The trigger takes a ReactNode, so the FAQ, the rows
sharing one card, and the flat list now set body-semibold on the
question and let question and answer separate on weight and colour
instead of size. Multiple Mode, Single Mode and Controlled keep `large`,
because there each trigger really is a section heading. The contrast
between the two is now the point rather than an accident.
Raw layout. Every block wrapped its content in
`<div style={{width: '100%', maxWidth: 400}}>` — a raw div with inline
styles, in the files we hold up as the reference for not doing that.
All six use `Stack maxWidth` now.
Content. Answers were one short sentence each, which is both unrealistic
for the patterns they illustrate and too small to show the reveal doing
any work. The FAQ (renamed from "Divided Accordion", since the name
described the mechanism rather than the use) now runs four real billing
questions with one- to three-paragraph answers.
Also:
- Controlled grows Previous/Next buttons, so it demonstrates external
control rather than three cards that happen to pass `value`.
- The FAQ's outbound link takes `hasUnderline`. `--color-text-accent`
resolves near-black in both the neutral and docsite themes, so an
unadorned standalone link is indistinguishable from body copy.
- `componentsUsed` in each doc.mjs matches what the block imports again.
- The storybook Dividers story follows the same type choice, with a note
on the story explaining it.
Test plan:
- pnpm check:repo and eslint clean.
- Verified on the docsite: no console errors, and a trigger-type audit
reports 14px/600 for the row-context examples and 17px/600 for the
surface-heading ones.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CollapsibleGroup had two blocks that between them covered one prop. "CollapsibleGroup — Accordion" was type="single" over three settings sections, which is what "Collapsible — Single Mode" already demonstrates, down to the same VStack and nearly the same section names — so the group's page spent a slot restating a neighbour. Meanwhile `density`, a documented group prop with three values, had no example anywhere in the repo. So the Accordion block becomes "CollapsibleGroup — Density": the same three sections at compact, balanced and spacious, stacked, with the label above each. Side by side is the only way that prop reads — 4px against 8px against 12px of row padding means nothing in isolation — and the description says what each step is for rather than restating the scale. The Showcase keeps its job (coordination: open one, the others close) and now says that is the point, including that nothing in the example tracks it — no state, no handlers, the group owns the open value. Its copy was also three sentences of placeholder shipping policy; it is shorter and real now. Both follow the trigger-type rule from the previous commit: the density example's rows share a surface so they take body-semibold, the Showcase's cards each own theirs so they keep the default `large`. componentsUsed matches the imports in both. Test plan: - pnpm check:repo, eslint, tsc clean. - Docsite CollapsibleGroup page: no console errors, and the three groups report data-density compact/balanced/spacious with 4px/8px/12px trigger padding and 14px/600 triggers.
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
Follow the simpler timing from aiforui.dev's FAQ: opacity now runs in parallel with height, on the same duration and curve, rather than waiting 95ms and arriving as a second event. Measured in Chromium, the normalized height and opacity progress differ by at most 0.001. Adopt the two things its accordion handles better: - Collapsed panels use `hidden="until-found"`, so Ctrl+F can find an answer behind a closed disclosure and the browser can reveal it on `beforematch`. `inert` lands immediately on close, keeping focus and the a11y tree out of a panel while it is still painting its exit; the hidden attribute lands after height finishes, so it does not blank the content on frame one. - Triggers now meet the WCAG 2.5.8 AA 24px target-size floor on precise pointers and the system's 44px comfortable-touch floor on coarse pointers. The split preserves desktop density — a flat 44px minimum would make compact, balanced and spacious identical in the data-heavy surfaces those settings exist for. `hidden="until-found"` and CSS height:auto need one deliberate frame of separation when opening. The attribute carries content-visibility: hidden; removing it and applying height:auto in one style recalc gives the transition no laid-out content height to travel to, so it snaps. Frame one removes the attribute and lays content out behind height:0; frame two applies auto. Browsers without interpolate-size derive visual state directly from isOpen and keep the old snap-open fallback instead. Test plan: - 72/72 Collapsible + CollapsibleGroup tests pass (two new: until-found/beforematch and target-size floor). - pnpm check:repo, core build, tsc and eslint clean. - Real docsite trace: hidden=until-found + inert at rest; inert=true on the first close frame while hidden remains absent for painting; hidden lands at transitionend; beforematch opens and clears both attributes. - Height and opacity progress differ <= 0.001 across the animation. - Coarse-pointer emulation reports min-height 44px; precise pointer is 24px undensified and existing density values continue to exceed it. - prefers-reduced-motion remains 1ms.
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the target-size and example updates look good, and I'd split those so they can land now.
The reveal's find-in-page path isn't live yet. hidden="until-found" still matches our [hidden] {display:none} reset, so closed panels remain unsearchable and beforematch never gets a chance to open them. The test dispatches that event directly, which skips the broken browser path.
Could we make until-found survive the reset and cover the actual browser path before landing the reveal?
[Reviewed by Robohands]
pr-visual already generated a static report with before/after/diff PNGs, then hid it in an Actions artifact ZIP. A link to a ZIP is not a visual review: the reviewer has to download, unzip, and match filenames before they can answer the one question the gate asks — is the after correct? The privileged workflow_run deployer now copies the static report beside the PR preview at /pr/<n>/visual/ without executing PR-controlled code. The PR analysis comment links the full wipe report and embeds the first three changed shots as a Before / After / Diff table, directly where the decision is made. The rest stay in the full report so a broad change does not make the comment unreadable. Verified against #5567's real visual-pr-report artifact: its two Collapsible deltas produce six inline image URLs plus the full-report URL.
The first #5572 cut copied PR-generated HTML/JS into a privileged gh-pages publisher and trusted the PR number inside a PR-produced artifact. A fork could redirect that publisher at another PR; an older out-of-order run could also overwrite evidence under the same mutable URL. The workflow now resolves PR identity from the GitHub API and cross-checks the artifact's PR/head/run. Default-branch code validates the verdict schema and safe key grammar, rejects symlinks and oversized files, decodes/re-encodes every PNG, and generates the report wrapper itself. PR-produced HTML/JS is neither executed nor published. Evidence paths are immutable by head SHA + run ID. An existing path with anything but byte-identical content is a hard failure. Inline image URLs point at the immutable raw branch path, independent of Pages deployment health; the full wipe UI uses Pages. Validated against #5567's real artifact plus negative controls for wrong run, path traversal/shell-shaped keys, and invalid PNG bytes.
The [hidden] reset was applying display:none to all hidden variants, including until-found. That kills the browser's native find-in-page indexing — content-visibility:hidden (the UA style for until-found) lets Ctrl+F scan the subtree, but display:none suppresses rendering entirely and beforematch never fires. Narrow the selector to :where([hidden]:not([hidden="until-found"])) so the Collapsible's find-in-page path actually works end-to-end.
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the reset exemption fixes the selector from my last review, but the browser-find path is still blocked. The closed panel remains inert, and inert subtrees are excluded from find-in-page, so the browser never reaches beforematch; the test still dispatches that event directly.
The released collapsible-content target also moved from the padded content to the zero-height clipping track. An existing 16px padding override now leaves every closed row 32px tall, and the permanent clip cuts the bottom 5px from a focused last child. This timing now spans two Effects, rAF, a timer, events, and native attributes without a focused browser test.
Could we preserve those content/focus contracts and move the timing protocol into a focused unit with real find-in-page coverage?
[Reviewed by Robohands]
* ci(pr-visual): put before, after, and diff where the reviewer sees them pr-visual already generated a static report with before/after/diff PNGs, then hid it in an Actions artifact ZIP. A link to a ZIP is not a visual review: the reviewer has to download, unzip, and match filenames before they can answer the one question the gate asks — is the after correct? The privileged workflow_run deployer now copies the static report beside the PR preview at /pr/<n>/visual/ without executing PR-controlled code. The PR analysis comment links the full wipe report and embeds the first three changed shots as a Before / After / Diff table, directly where the decision is made. The rest stay in the full report so a broad change does not make the comment unreadable. Verified against #5567's real visual-pr-report artifact: its two Collapsible deltas produce six inline image URLs plus the full-report URL. * fix(pr-visual): use durable raw image URLs and keep report publishing trusted * security(pr-visual): publish immutable evidence from trusted base code The first #5572 cut copied PR-generated HTML/JS into a privileged gh-pages publisher and trusted the PR number inside a PR-produced artifact. A fork could redirect that publisher at another PR; an older out-of-order run could also overwrite evidence under the same mutable URL. The workflow now resolves PR identity from the GitHub API and cross-checks the artifact's PR/head/run. Default-branch code validates the verdict schema and safe key grammar, rejects symlinks and oversized files, decodes/re-encodes every PNG, and generates the report wrapper itself. PR-produced HTML/JS is neither executed nor published. Evidence paths are immutable by head SHA + run ID. An existing path with anything but byte-identical content is a hard failure. Inline image URLs point at the immutable raw branch path, independent of Pages deployment health; the full wipe UI uses Pages. Validated against #5567's real artifact plus negative controls for wrong run, path traversal/shell-shaped keys, and invalid PNG bytes. * security(pr-visual): validate and publish immutable evidence from trusted code Review found three trust-boundary defects in the initial publisher: it trusted a PR number supplied by a PR-controlled artifact, copied PR-generated HTML/JS to the shared Pages origin, and used a mutable per-PR URL that an old run could overwrite. The workflow_run now resolves PR identity through the GitHub API and requires repo/head/run metadata to agree. Default-branch code validates verdict schema, counts and key grammar, rejects symlinks/oversized files, decodes and re-encodes all PNGs, and generates the HTML wrapper itself. Evidence publishes under an immutable head-SHA/run-ID path; different bytes at an existing path are a hard failure. Inline images use the immutable raw branch URL so Pages deployment health cannot break the PR evidence. No pull_request_target or workflow_run step checks out or executes PR code.
Replace the hidden="until-found" + inert + rAF timing protocol with the same grid-template-rows: 1fr → 0fr technique SideNavItem already uses. This eliminates: - The multi-frame open/close timing protocol (rAF + transitionend + setTimeout) - The hidden="until-found" imperative attribute management - The beforematch event listener for find-in-page - The canInterpolateSize feature detection - The FALLBACK_SETTLE_MS constant - The reset.css exemption for hidden="until-found" The new approach is pure CSS — no JS timing, no imperative DOM writes. grid-template-rows transitions are well-supported and battle-tested in the codebase (SideNavItem ships the same pattern). The content track uses inert + aria-hidden when collapsed, matching SideNavItem exactly. The opacity crossfade is preserved as a parallel transition on the inner content element.
|
Addressed the latest review in 402fd54:
Verified with the 40-test Collapsible suite, strict lint/repo checks, Core typechecks, Core build, and formatting. |
Resolve the RTL audit exemption list: main already carries the same core/Collapsible entry this branch added, plus newer entries, so keep main's list unchanged.
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the chevron, keyboard, reduced-motion, target-size, theme-target, and block rewrites are otherwise in good shape.
The current Collapsible contract intentionally keeps reveal motion unchanged; this head replaces instant hide/show with grid and opacity animation plus mounted inert content. That needs a separate approved decision, so could we keep reveal behavior unchanged here?
The Controlled block also lets the active row close, then displays “Step 0 of 3”; Next returns to Profile instead of advancing. Could we either keep one step open or model the empty state explicitly?
[Reviewed by Robohands]
cixzhang
left a comment
There was a problem hiding this comment.
Thanks, this now keeps Collapsible behavior unchanged and the controlled block always has a valid step. The scoped CLI examples and patch release checks look good.
[Reviewed by Robohands]
What
Refreshes the shipped Collapsible and CollapsibleGroup block templates with complete examples for:
The controlled step example now keeps one valid step open, so closing the active row cannot produce “Step 0 of 3” or make Next wrap back to Profile.
Scope correction
This PR no longer changes Collapsible runtime behavior, reveal motion, component tests/docs, or Storybook. Current
component:Collapsibleauthority preserves reveal behavior unless separately approved, so all grid/opacity/inert motion work was removed.Validation
Changeset
CLI patch only. No Core package change.