Skip to content

feat(SelectableCard, SelectableCardGroup): a card joins its group by value - #13733

Draft
ernestt wants to merge 3 commits into
mainfrom
feat/selectablecard-group-value
Draft

ernestt wants to merge 3 commits into
mainfrom
feat/selectablecard-group-value

Conversation

@ernestt

@ernestt ernestt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

SelectableCardGroup to Core, two pull requests. Review and merge in this order; each is based on the one before it, and both should ship in the same release (see "Release order").

  1. feat(SelectableCard, SelectableCardGroup): a card joins its group by value #13733: a SelectableCard with a value is a member of the SelectableCardGroup around it ← this pull request
  2. feat(core): SelectableCardGroup moves to Core #13734: SelectableCardGroup moves to Core

User need

A product that asks people to choose among a few rich options, such as a plan, a shipping speed or a layout, shows them as cards. For one choice, keyboard and screen-reader users need a radio group: one tab stop, the arrow keys, and the position spoken. Today that takes Lab's SelectableCardGroup and its own card component, SelectableCardGroupItem, which repeats every SelectableCard prop except isSelected and onChange. Core's SelectableCard cannot be one choice of a set at all: its record keeps single-select out of its public contract until the group is in Core.

So a builder learns two card components for one job, and the group cannot move to Core while its cards are a second API for that job (architecture:public-component-api INV21, one API per job).

Problem and solution fit

  • value on SelectableCard. A card with a value, in place of isSelected and onChange, is a member of the SelectableCardGroup around it. The group gives it its selection, its input (a radio in a single choice, a checkbox in several), its input name and its disabled default, and the card sends the group its selection requests. A radio only selects.
  • The group's children are SelectableCards. SelectableCardGroupItem and SelectableCardGroupItemProps are removed from Lab. The group provides one private context instead of wrapping each card.
  • The chosen card submits a single choice. The chosen, enabled radio card renders the hidden input that submits the group's value under htmlName. The item wrapper used to render it beside the card.
  • Membership stops at a layer. A card with a value in a popover or a dialog opened inside the group is not a member (spec:AST-038 FR7, FR8), as ToggleButtonGroup's context already behaves.
  • The record admits it. component:SelectableCard describes the member case: DEC-1 (a card joins a group by value), a Group value concept, and FR1, FR2, FR5 and AR1 for a radio member.
  • Lab still reaches the context through Core's internal selectable-card entry, which keeps its SelectableCardInputContext export from the same selectableCardInput.ts module; the context now carries each member's input, selection and disabled default. feat(core): SelectableCardGroup moves to Core #13734 removes the context exports and joinAriaIDs from that entry when the group moves to Core; the entry keeps useFieldInputStyling.

Current specification

  • component:SelectableCard (current): its ownership boundary kept single-select out of the public contract "until the group is promoted to Core". This pull request amends it, so it needs an engineering owner's /approve-spec.
  • component:SelectableCard DEC-1, added here: a member identified by value takes its selection from its group, as a ToggleButtonGroup member does (family:buttons FR11). Rejected: a separate item component that wraps the card.
  • spec:AST-002 FR15 (invalid states are prevented where practical): a card is typed as standalone or as a member, never both.
  • spec:AST-017 FR25 (outside a declared minor, type changes are additive): SelectableCardProps keeps its members and gains only value?: never; the member shape is a new type. SelectableCard has two call signatures, the member one first, so ComponentProps<typeof SelectableCard> stays SelectableCardProps.
  • spec:AST-038 FR7, FR8 (group membership stops at a layer boundary).

Public delta and caller burden

Core:

export interface SelectableCardProps extends Omit<BaseProps, 'onChange'> {
  // …every released member, unchanged…
  value?: never; // new
}

export interface SelectableCardMemberProps // new
  extends Omit<SelectableCardProps, 'isSelected' | 'onChange' | 'value'> {
  value: string;
  isSelected?: never;
  onChange?: never;
}

export function SelectableCard(props: SelectableCardProps | SelectableCardMemberProps): ReactNode;
  • A standalone card keeps its props, defaults, DOM and behavior. SelectableCardProps stays an interface, and ComponentProps<typeof SelectableCard> stays SelectableCardProps, so interface X extends ComponentProps<typeof SelectableCard> and Omit<ComponentProps<typeof SelectableCard>, …> keep working; a test pins both.
  • TypeScript rejects isSelected or onChange beside value, and a card with neither.
  • Outside a group, a card with a value renders unselected and inert: it is disabled, so it reads as disabled, shows no hover or press paint, and ignores clicks and keys.
  • A member's own isDisabled adds to the group's: a disabled group disables every card, and an enabled group does not enable a card that disables itself. A disabled member submits nothing.

Lab (canary only): SelectableCardGroup's children are SelectableCards, and SelectableCardGroupItem and SelectableCardGroupItemProps are removed.

// Before
<SelectableCardGroup label="Add-ons" type="multiple" value={addOns} onChange={setAddOns}>
  <SelectableCardGroupItem value="backup" label="Daily backup">
    <Text>$5 a month</Text>
  </SelectableCardGroupItem>
  <SelectableCardGroupItem value="support" label="Priority support" isDisabled>
    <Text>$20 a month</Text>
  </SelectableCardGroupItem>
</SelectableCardGroup>

// After
<SelectableCardGroup label="Add-ons" type="multiple" value={addOns} onChange={setAddOns}>
  <SelectableCard value="backup" label="Daily backup">
    <Text>$5 a month</Text>
  </SelectableCard>
  <SelectableCard value="support" label="Priority support" isDisabled>
    <Text>$20 a month</Text>
  </SelectableCard>
</SelectableCardGroup>

The caller's one new decision: give a card a value (a member) or isSelected and onChange (standalone). In a group's DOM, one thing moves: the hidden input that submits a single choice sits inside the chosen card, after its radio, instead of after the card. No theming target, data attribute, token or string changes.

Owner decision in this pull request: the name of the new public type, SelectableCardMemberProps. The record names it, so approving the record approves the name.

Design and alternatives

  • Rejected: SelectableCardProps as a union of a standalone shape and a member shape. It would make invalid combinations unrepresentable with no new type name, but it turns a released interface into a union: interface X extends SelectableCardProps stops compiling (TS2312), and so does passing an Omit<SelectableCardProps, …> back to the card. That is a breaking type change, which spec:AST-017 FR25 keeps out of a patch release.
  • Rejected: optional isSelected and onChange, ignored inside a group, as ToggleButton ignores isPressed. It makes required props optional for code that reads them, and it lets a broken combination type-check (spec:AST-002 FR15).
  • Rejected: keeping SelectableCardGroupItem (DEC-1; INV21).
  • The card renders the radio's hidden form input, because without a wrapper only the card knows when it is both chosen and enabled.

Release order

Core's output names no Lab surface (spec:AST-017 FR27): its JSDoc, SelectableCard.doc.mjs and the Changeset say "card group", and the card has no development warning that names one. SelectableCardGroup itself stays Lab-only until #13734.

Evidence

Real-browser screenshots of the Lab/SelectableCardGroup stories, from a static Storybook build of main and of this branch, served locally and captured in headless Chromium at 2× scale, scoped to #storybook-root.

State Before (main) After
Single choice before after
Keyboard focus, after Tab and ArrowRight before after
Multiple choice, after two clicks before after
Disabled group before after
Gothic, dark before after
Forced colors before after

All 14 captured states are pixel-identical before and after (0 differing pixels). The others: chose Team, multiple, vertical, two forms, one htmlName, dark, Y2K, right to left, 320 px wide. In every state each input's type, value, checked state, form owner and aria-disabled also match before and after.

  • Unit (SelectableCardRadio.test.tsx): radio and checkbox members, Enter and click on a chosen radio, group and member disabled (each blocks selection and form submission), the chosen card's form value, a card without a value in a group, a card with a value outside a group, a card in a layer inside a group, and the props types (@ts-expect-error for "both" and "neither", and extends and Omit on SelectableCardProps).
  • The layer case fails with a plain shared context in place of the layer-scoped one, and both @ts-expect-error cases fail with optional props in place of the two types.
  • Chromium (SelectableCardGroupRadio.a11y.chromium.spec.ts): one tab stop, arrows that move and select with wrapping, Space, a click on the chosen card, and two groups that share an htmlName in separate forms. The SelectableCard states of Checkbox.a11y.chromium.spec.ts, CardPress, FocusRingOwner and ReducedMotionPress pass unchanged.

Scope

Components: SelectableCard, SelectableCardGroup

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Writing rubric results

docs/specs/components/SelectableCard/SelectableCard.spec.md:

  • R1 narration: none; the amended Intent, ownership and concept rows are present tense.
  • R2 research: none; the alternatives above stay in this description.
  • R3 evidence: the new verification row names tests (SelectableCardRadio.test.tsx, SelectableCardGroup's tests and its Chromium spec), not changes.
  • R4 rejected alternatives: one, in DEC-1, one line.
  • R5 change references: none.
  • R6 open questions: none.
  • R7 project status: none. The rows this pull request rewrites (Compatibility/readiness, FR2 and FR5) keep main's wording for the staged layer-click change and its implementation gap.

Testing

Local gates on the first version of this branch, over main at aee3fa9:

  • pnpm preflight --browser: review:pre (0 findings), build, typecheck of the changed packages and their dependents, ESLint and Prettier on the changed files, check:repo, Vitest ui (842 files, 21,246 tests) and node (1,782 files, 27,833 tests, including all 8 swizzle-proof slices: 182 targets, 0 failures), check:knowledge, check:changesets, the Storybook build, and the 133 accessibility-contract specs the change selects all pass. The change selects the full Chromium interaction suite (2,008 tests, one worker); 1,847 passed before the local run hit its time limit, and the remaining files (NavigationStack, PageControl, RefreshControl, TabBar, Tour) then passed on their own: 206 passed, 1 skipped by its spec, none failed. The last commit after that run only adds the new type to the file header's @output line; strict ESLint and Prettier pass on it.

  • pnpm exec vitest run packages/core/src/SelectableCard packages/lab/src/SelectableCardGroup: 41 passed.

  • pnpm storybook:build, then playwright test --project=chromium SelectableCardGroupRadio: 4 passed; the SelectableCard states of Checkbox.a11y.chromium.spec.ts, CardPress, FocusRingOwner and ReducedMotionPress: 70 passed.

  • ASTRYX_STRICT_LINT=1 eslint on the changed files: 0 errors. pnpm review:pre: 0 findings. pnpm check:knowledge: aligned, with 27 status warnings against main's 29.

  • A second agent session that did not write the change reviewed it against the pre-review checklist; its findings are fixed here (the props types, the R7 rows, a disabled checkbox member's form test, and the comments).

  • Rebased onto main at d63c249. The diff is unchanged (identical patch id), and pnpm preflight passes again on this head: review:pre (0 findings), build, typecheck, lint, Vitest ui and node (including all 8 swizzle-proof slices, 0 failures), check:knowledge and check:changesets, ending "ready to flip".

  • Rebased onto main at a92c1ce. Conflicts came up in two files only, the SelectableCard record and SelectableCard.doc.mjs; the other 18 files' changes are unchanged (same per-file patch ids). Main has since made the card's target reflect data-disabled, added the forced-colors selection ring, reworded the record's project-status phrases, and renamed the label description. The resolved record keeps all of that and adds this pull request's member wording: the Contract-at-a-glance rows, the compatibility class, the Selection, Disabled and Group value concepts, FR1, FR2, FR4 and FR5, the radio-member state, and the group verification row. The source reads the effective disabled state for data-disabled, so a member of a disabled group carries it too, and FR5 says so. The label description now also names the radio a single-choice member renders. Prettier re-aligned the record's tables. On this head pnpm preflight passes: review:pre (0 findings), build, typecheck, lint, Vitest ui (21,829 tests) and node (28,234 tests, including all 8 swizzle-proof slices, 0 failures), check:knowledge (aligned, no warnings, as on main) and check:changesets, ending "ready to flip". The screenshots above predate this rebase.

Main merge (c903d9b, a maintainer carry; the commit above is unchanged): in docs/specs/components/SelectableCard/SelectableCard.spec.md, the verification map keeps main's rows, including its updated "FR2 (nested)" row, and adds this branch's "Group membership" row. No other change.

Maintainer carry at d4f41c2 (Co-authored-by: @ernestt)

(Posted by Cindy's agent.) Six review fixes in one push; @ernestt's design and record approval are unchanged.

Fix Why Reuses
Two call signatures, the member one first ComponentProps<typeof SelectableCard> was a union, so interface X extends ComponentProps<typeof SelectableCard> and an Omit spread stopped compiling in a patch (spec:AST-017 FR25). The last signature is the standalone interface again. FieldStatus's overload pattern
A card with a value outside a group is disabled The approved Group value row says it renders unselected and inert; it still ran onClick, showed hover and press paint, and read as an enabled checkbox. SelectableCard's own disabled path
No development warning The inert card shows the mistake, and the warning was most of the added size. none needed
Core says "card group", not SelectableCardGroup Stable output names no experimental surface (spec:AST-017 FR27). none needed
Membership context stays in selectableCardInput.ts as SelectableCardInputContext No new internal module (architecture:knowledge-contracts DEC-22); Core's internal/selectable-card entry is unchanged from main. the existing internal module and createLayerScopedContext
Corrected description claims The #13734 sentence, FR25, the standalone and stray-card lines, and the FR27 paragraph now say what ships. none needed

Red first, at c903d9b with the new tests: "a card with a value outside a group stays unselected and inert" fails (its onClick runs, no aria-disabled), and Core's typecheck fails the extended-props test with TS2312. Both pass at d4f41c2.

First-load size (the size report's measureEntry, a page that imports SelectableCard): main b3411f8 18,010 B; c903d9b 18,339 B (+329 B); d4f41c2 18,131 B (+121 B, under the 307 B that architecture:component-import-boundaries INV10 allows an opt-in feature).

Checks at d4f41c2: SelectableCard and Lab SelectableCardGroup tests 49/49; Core, Lab and Storybook typechecks clean; strict eslint 0 errors; Prettier clean; swizzle-proof samples 24 passed; pnpm check:knowledge aligned.

Story: Core/SelectableCard gains ValueOutsideAGroup, a standalone card beside a card with a value and no group.

@vercel

vercel Bot commented Nov 24, 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 Dec 3, 2026 3:21pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 24, 2026
@astracat-bot

astracat-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Dec 3, 2026, 3:38 PM UTC

@github-actions github-actions Bot added needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:spec-owner-review Current knowledge records await owner approval labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

…value

A SelectableCard with a `value` in place of `isSelected` and `onChange` is a
member of the SelectableCardGroup around it. The group gives the card its
selection, its input (a radio in a single choice, a checkbox in several), its
input name and its disabled default, and the card sends the group its
selection requests. Membership stops at a layer boundary.

The new SelectableCardMemberProps type describes a member. SelectableCardProps
stays an interface and gains only `value?: never`, so TypeScript rejects
`isSelected` or `onChange` beside `value`. Outside a group, a card with a
`value` warns in development and stays unselected.

Lab's SelectableCardGroup takes these cards as its children, so
SelectableCardGroupItem and SelectableCardGroupItemProps are removed. The
`component:SelectableCard` record admits `value` (DEC-1).
@ernestt
ernestt force-pushed the feat/selectablecard-group-value branch from a60f64c to 9e86180 Compare December 1, 2026 22:57
@ernestt

ernestt commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main at a92c1ce; the new head is 9e86180. Conflicts came up only in the SelectableCard record and SelectableCard.doc.mjs, where main had added the card's data-disabled reflection, the forced-colors selection ring and new wording. The resolution keeps all of main's changes and adds this pull request's member wording; the label description now also names the radio a single-choice member renders. The other 18 files' changes are unchanged (same per-file patch ids).

On this head, pnpm preflight passes (review:pre 0 findings, build, typecheck, lint, Vitest ui and node, check:knowledge, check:changesets). The Testing section of the description has the details.

@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 9e86180

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 3, 2026
docs/specs/components/SelectableCard/SelectableCard.spec.md: the
verification map keeps main's rows and this branch's group-membership row.
No other change.
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Dec 3, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Dec 3, 2026
@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec c903d9b

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 3, 2026

@astracat-bot astracat-bot Bot 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.

Changes requested. The amended SelectableCard record is approved at this head; these code and description issues still need to change:

  • The card's props type stops being extendable in a patch release: changing SelectableCard's parameter to SelectableCardProps | SelectableCardMemberProps makes interface X extends ComponentProps<typeof SelectableCard> fail (TS2312) and stops Omit<ComponentProps<typeof SelectableCard>, …> from spreading back onto the card (TS2322), a type break that spec:AST-017 FR25 rules out in a patch and that makes "A standalone card does not change" (Changeset), "keeps its props" (description) and "additive" (record) untrue, so declare two overloads, the member signature first and the standalone one last, which compile locally and still reject both and neither.
  • New internal shared module that no record names: selectableCardGroupContext.ts, re-exported through Core's internal/selectable-card entry for Lab, needs SelectableCardGroupContext and its membership shape named in the SelectableCard record with why SelectableCardInputContext was not enough (architecture:knowledge-contracts DEC-22), and that record edit then needs a fresh /approve-spec.
  • Stable Core output names a Lab-only component: the development warning, the exported JSDoc, SelectableCard.doc.mjs and the Core Changeset point consumers at SelectableCardGroup, which spec:AST-017 FR27 forbids while the group is in Lab, so merge this together with the group's move to Core or keep those mentions out of Core until then.
  • Every SelectableCard page pays 329 bytes gzip for an opt-in feature: measured locally with the boundary check's own measurement, a page that renders SelectableCard without value loads 18,339 instead of 18,010 bytes of gzip JavaScript, over the 0.3 KB architecture:component-import-boundaries INV10 allows, and dropping the useDevWarning call brings the growth to 109 bytes.
  • A card with a stray value is not inert: the description and the approved Group value row say such a card "renders unselected and inert", but it keeps its hover and press paint, runs the caller's onClick and stays an enabled checkbox, so treat a card with a value and no group as disabled and assert that in its test.
  • The description misstates what #13734 does: that pull request keeps Core's internal/selectable-card entry and removes only the context exports and joinAriaIDs, so reword "#13734 removes the entry when the group moves to Core."

The member behaviour itself checks out locally: the three test files pass, the type guards reject both and neither, and membership stops at a layer.

Claims and files checked

Review mode: full; reason: recipe-changed (many rules)

Claims:

  • Title: a card joins its group by value: verified (SelectableCard.tsx:518-547; member tests in SelectableCardRadio.test.tsx, run locally)
  • Changeset: a card with a value is a member of the group around it, which gives it its selection, input and disabled default: verified (SelectableCard.tsx:520-536; radio, checkbox and disabled member tests, run locally)
  • Changeset: in a single choice the card is a native radio that selects and never deselects itself: verified (SelectableCard.tsx:536, :544-545; the "never deselects itself" test)
  • Changeset: in a multiple choice the card is a checkbox that submits its value under the group's name: verified (SelectableCard.tsx:673-674; Lab group sets the input name to the submit name; checkbox member test)
  • Changeset: a new props type describes a member: verified (SelectableCard.tsx:404-418; SelectableCard/index.ts)
  • Changeset and description: the existing props type stays an interface and gains only an optional never-typed value, so extending it and omitting from it keep working: verified (built API surface of both trees; the props-type test, compiled locally)
  • Changeset and description: TypeScript rejects isSelected or onChange beside value, and a card with neither: verified (compiled locally; the test's expect-error lines pass CI typecheck)
  • Changeset: outside a group, a card with a value warns in development and stays unselected: verified (SelectableCard.tsx:522-530; test at SelectableCardRadio.test.tsx:337)
  • Changeset: a standalone card does not change: false (derived props types break, TS2312 and TS2322, compiled locally)
  • Description: today a single choice needs Lab's own item component, which repeats the card's props, and the card's record keeps single choice out of its contract: verified (base group source and base record)
  • Description: the group gives a member its selection, input, input name and disabled default, the card sends selection requests, and a radio only selects: verified (SelectableCard.tsx:520-547)
  • Description: the group's children are SelectableCards, the item component and its props type are removed, and one private context replaces the wrapper: verified (Lab index files; no remaining reference anywhere in the repository, searched)
  • Description: the chosen, enabled radio card renders the hidden input that submits the group's value under its form name: verified (SelectableCard.tsx:693-695; form-value test)
  • Description: membership stops at a layer, in a popover or a dialog, as the toggle-button group's context does: verified (layer test, run locally; every layer renders the same content boundary; the toggle-button group uses the same layer-scoped context)
  • Description: the card's record admits the member case with a decision, a group value concept and the member contract: verified (record diff; approved at this head)
  • Description: Lab reaches the context through Core's internal entry, which now exports the group context: verified (internal/selectable-card.ts:18-19)
  • Description: the follow-up pull request removes that entry: false (its diff keeps the entry)
  • Description: a card is typed as standalone or as a member, never both: verified (compiled locally)
  • Description: under the compatibility rule the change is additive because the props type keeps its members and the member shape is a new type: false for the component's derived props type (compiled locally)
  • Description: the public delta block shows the union parameter: matches the code (SelectableCard.tsx:513), which is the compatibility finding
  • Description: a standalone card keeps its props, defaults, DOM and behaviour: false for its derived props type; defaults, DOM and behaviour verified (SelectableCard.test.tsx, 21 tests, run locally)
  • Description: outside a group, a card with a value warns once in development and renders unselected and inert: warns once per card and unselected verified; inert false (SelectableCard.tsx:621, :644, :654, :683; probed locally)
  • Description: a member's own disabled state adds to the group's, and a disabled member submits nothing: verified (SelectableCard.tsx:533, :679, :693; disabled and form tests)
  • Description: in a group's DOM only the hidden submit input moves, with no theming target, data attribute, token or string change: verified by comparing both render paths (no new target, attribute, token or catalog string; the only new text is a console development warning)
  • Description: the new type name is the owner decision, approved with the record: verified (approved at this head)
  • Description: the rejected designs and why the card renders the hidden input: reasoning; the shipped union parameter has the same extension break the description gives for rejecting a union props type
  • Description: this should not ship in a release without the follow-up pull request: reported intent; nothing enforces it (stable-output finding)
  • Description: before and after screenshots, pixel-identical, with matching input attributes: reported (taken before the last rebase)
  • Description: the listed unit cases: verified by reading and running the three test files locally (49 passed); mutation and Chromium results: reported (the Chromium spec runs in deferred CI)
  • Description: local preflight and test runs: reported
  • Description: the latest main merge only keeps main's verification rows and adds this branch's row: verified (per-file patch comparison with the previous head; only the nested-control row differs, as on main)
  • Description: scope checklist (one capability, no unrelated changes, docs and tests ship, no internal context): verified (no tagalong; public text clean)
  • Description: writing rubric results for the record: verified (present tense; one rejected alternative; the rewritten rows keep main's gap wording)

Files:

  • .changeset/selectable-card-group-value.md: finding (names the Lab-only group; "A standalone card does not change")
  • apps/storybook/stories/SelectableCardGroup.stories.tsx: clear
  • docs/specs/components/SelectableCard/SelectableCard.spec.md: finding (the Owns bullet does not name the context; "inert" in the Group value row; "additive" compatibility rows)
  • packages/cli/test/swizzle-proof/samples.mjs: clear
  • packages/core/src/SelectableCard/SelectableCard.doc.mjs: finding (names the Lab-only group)
  • packages/core/src/SelectableCard/SelectableCard.tsx: finding (union parameter; Lab-only name in the warning and JSDoc; size; stray value stays interactive)
  • packages/core/src/SelectableCard/SelectableCardRadio.test.tsx: finding (the "inert" test checks only selection)
  • packages/core/src/SelectableCard/index.ts: clear
  • packages/core/src/SelectableCard/selectableCardGroupContext.ts: finding (no record names it)
  • packages/core/src/SelectableCard/selectableCardInput.ts (deleted): clear
  • packages/core/src/internal/selectable-card.ts: finding (re-exports the unnamed module)
  • packages/lab/blocks/SelectableCardGroupShippingSpeed.doc.mjs: clear
  • packages/lab/blocks/SelectableCardGroupShippingSpeed.tsx: clear
  • packages/lab/blocks/SelectableCardGroupShowcase.doc.mjs: clear
  • packages/lab/blocks/SelectableCardGroupShowcase.tsx: clear
  • packages/lab/src/SelectableCardGroup/SelectableCardGroup.doc.mjs: clear
  • packages/lab/src/SelectableCardGroup/SelectableCardGroup.test.tsx: clear
  • packages/lab/src/SelectableCardGroup/SelectableCardGroup.tsx: clear
  • packages/lab/src/SelectableCardGroup/index.ts: clear
  • packages/lab/src/index.ts: clear

Automated review (maintainer link)

…inert

- Two call signatures, the member one first, keep
  `ComponentProps<typeof SelectableCard>` the standalone interface, so a
  wrapper that extends or omits from it compiles again.
- A card with a `value` outside a group is disabled: no click, no hover or
  press paint, and its checkbox reads as disabled.
- Drop the development warning. The inert card shows the mistake, and the
  warning was most of the card's added bundle size.
- Core's JSDoc, doc and changeset say "card group" and name no Lab surface.
- Keep the internal `selectableCardInput.ts` module and its
  `SelectableCardInputContext` name for the group's membership context,
  instead of a new module.
- Add a story for a card with a value outside a group.

Co-authored-by: Ernest Tien <ernesttien@meta.com>
@cixzhang
cixzhang marked this pull request as draft December 3, 2026 15:03
@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec d4f41c2

@astracat-bot astracat-bot Bot 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.

Changes requested. The member API works as described, and the amended SelectableCard record is approved at this head. Three statements do not match what this head ships:

  • The record promises a development warning the code no longer emits: the record's Group value row says a card with a value outside a group "warns in development", but this head only disables it, so reword that sentence (for example "renders unselected and disabled (FR5)") and have an engineering owner re-approve the record.
  • The description's public delta still shows the union signature: the code block under "Public delta and caller burden" declares SelectableCard(props: SelectableCardProps | SelectableCardMemberProps): ReactNode, so replace it with the two overloads this head ships.
  • Formatting churn contradicts the scope checklist: SelectableCard.doc.mjs re-wraps entries this change does not touch (usage, anatomy, padding, variant, elevation, xstyle, theming), so restore main's layout for those entries or uncheck "Unrelated fixes, cleanup, and policy changes were removed or split".

Non-blocking:

  • Bump the context's protocol version: SelectableCardInputContext changed its value's shape but keeps version 1, and version 2 would keep an older Core copy from reading the new shape.
  • The context's JSDoc names too narrow a layer: its comment says membership stops for a layer "opened from a member", but it stops for any layer opened inside the group.

Run locally, the targeted tests (49), the Lab typecheck, strict lint and the knowledge check pass, and the page that renders the card grows by 121 bytes gzip.

Claims and files checked

Review mode: full; reason: requested

Claims:

  • Title: a card joins its group by value: verified (member path in the card; member tests run locally)
  • Changeset: a card with a value takes selection, input and disabled default from its group: verified (member tests)
  • Changeset: in a single choice the card is a radio that never deselects; in several choices it submits its value under the group's name: verified (radio and checkbox member tests, form data)
  • Changeset: a new member props type; the standalone props stay an interface and gain only a never-typed value, so both together are rejected: verified (generated API delta; local typecheck)
  • Changeset: a card with a value outside a group is unselected, reads as disabled and ignores clicks: verified (test; story probe)
  • Changeset: a standalone card keeps its props type, DOM and behavior: verified (unchanged standalone tests pass; probe)
  • Description: the Lab item repeated every card prop except selection and change: verified (base Lab source)
  • Description: the card record kept single-select out of its public contract: verified (base record)
  • Description: members take input type, name and disabled default from the group, send it requests, and a radio only selects: verified (code; tests)
  • Description: the Lab item and its props type are removed, and the group provides one private context: verified (no references remain)
  • Description: the chosen, enabled radio card renders the hidden submit input: verified (form-data test; DOM probe)
  • Description: membership stops at a popover or dialog opened inside the group: verified (dialog test; popovers render the same layer boundary)
  • Description: Lab reaches the context through Core's unchanged internal entry, and the follow-up removes the context exports and the aria-id joiner: verified (entry identical to base; follow-up's file at its head)
  • Description: the record amendment needs an owner approval: verified (approved at this head)
  • Description: a card is typed as standalone or member, never both, and two call signatures keep the derived props the standalone interface: verified (local typecheck)
  • Description: Public delta block declares one union-typed signature: false (two overloads ship)
  • Description: a standalone card keeps props, defaults, DOM and behavior; extending and omitting the derived props keep working: verified (typecheck of the test that pins both)
  • Description: a stray card shows no hover or press paint and ignores clicks and keys: verified (disabled path; test)
  • Description: a member's own disabled state adds to the group's, and a disabled member submits nothing: verified (tests)
  • Description: in a group's DOM only the hidden submit input moves; no theming target, data attribute, token or string changes: verified (DOM probe; identical frames; API delta)
  • Description: Core output names no Lab surface and has no development warning: verified (search of Core source, docs and changeset)
  • Description: screenshots and pixel-identical states: reported (consistent with the identical frames captured locally)
  • Description: listed unit cases: verified (each present; run locally)
  • Description: mutation and red-first results: reported
  • Description: browser spec results: reported (CI has not run)
  • Description: one capability is added: verified
  • Description: unrelated fixes and cleanup were removed or split: false (the docs file is re-wrapped)
  • Description: docs, tests and migration ship; no internal context: verified
  • Description: writing rubric results for the record: verified
  • Description: preflight and test runs: reported; the targeted tests, Lab typecheck, strict lint and knowledge check re-run locally
  • Description: first-load size moves from 18,010 to 18,131 bytes: verified (measured locally); the previous head's figure: reported
  • Description: a new story shows a card with a value outside a group: verified

Files:

  • .changeset/selectable-card-group-value.md: clear
  • apps/storybook/stories/SelectableCard.stories.tsx: clear
  • apps/storybook/stories/SelectableCardGroup.stories.tsx: clear
  • docs/specs/components/SelectableCard/SelectableCard.spec.md: finding (stray-card warning sentence)
  • packages/cli/test/swizzle-proof/samples.mjs: clear
  • packages/core/src/SelectableCard/SelectableCard.doc.mjs: finding (layout-only churn)
  • packages/core/src/SelectableCard/SelectableCard.tsx: clear
  • packages/core/src/SelectableCard/SelectableCardRadio.test.tsx: clear
  • packages/core/src/SelectableCard/index.ts: clear
  • packages/core/src/SelectableCard/selectableCardInput.ts: two non-blocking notes
  • packages/lab/blocks/SelectableCardGroupShippingSpeed.doc.mjs: clear
  • packages/lab/blocks/SelectableCardGroupShippingSpeed.tsx: clear
  • packages/lab/blocks/SelectableCardGroupShowcase.doc.mjs: clear
  • packages/lab/blocks/SelectableCardGroupShowcase.tsx: clear
  • packages/lab/src/SelectableCardGroup/SelectableCardGroup.doc.mjs: clear
  • packages/lab/src/SelectableCardGroup/SelectableCardGroup.test.tsx: clear
  • packages/lab/src/SelectableCardGroup/SelectableCardGroup.tsx: clear
  • packages/lab/src/SelectableCardGroup/index.ts: clear
  • packages/lab/src/index.ts: clear

Automated review (maintainer link)

| Selection | selected; unselected | Controlled checked state, reflected as `data-selected`; a member's comes from its group. | Always | Required standalone; from the group for a member | `component:SelectableCard` | Stable | — |
| Disabled | enabled; disabled | Blocks toggling while keeping the input focusable, reflected as `data-disabled`; a group's `isDisabled` disables every member. | Always | enabled | `component:SelectableCard` | Stable | — |
| Variant | Card variants; theme additions | Card paint and the matching selection ring color. | Always | `default` | `component:Card` | Stable | A theme-added variant rings in `--selectable-card-ring-color` (default `--color-accent`) and keeps its border color. |
| Group value | a string | Identifies the card as a `SelectableCardGroup` member; the group's `value` names the selected members. | Inside `SelectableCardGroup` | none | `component:SelectableCard` | Stable | TypeScript rejects `isSelected` or `onChange` beside it (`spec:AST-002` FR15). Outside a group, a card with a `value` warns in development and renders unselected and inert. |

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.

"warns in development": this head removed the warning, so a card with a value outside a group is only disabled (SelectableCard.tsx:533-542). Reword the sentence to what ships, for example "Outside a group, a card with a value renders unselected and disabled (FR5).", which also says what "inert" leaves open (the card stays focusable and is announced unavailable).

{name: 'variant', type: "'default' | 'transparent' | 'muted' | 'blue' | 'cyan' | 'gray' | 'green' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow'", description: 'Background color variant.', default: "'default'"},
{name: 'elevation', type: "'none' | 'low' | 'med' | 'high'", description: 'Resting shadow depth. The selection ring composes on top, so a selected card keeps its shadow.', default: "'none'"},
{
name: 'padding',

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.

From here to xstyle, and in usage, anatomy, theming, the playground and the dense descriptions, the entries only change layout: no hook or CI step formats .mjs. Restoring main's one-line layout for entries this change does not touch keeps the docs diff to the entries the member API changes.

*/
export const SelectableCardInputContext =
createSharedContext<SelectableCardInput | null>(
createLayerScopedContext<SelectableCardInput | null>(

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.

Non-blocking: the context value's fields changed (type, name, value became inputType, inputName, submitName, isDisabled, isSelected, onMemberChange), but the protocol version stays 1. sharedKey documents that "The version names the value's shape". Version 2 keeps an older Core copy on the page from reading the new shape.

/** Without a provider, a card renders its own checkbox. */
/**
* Without a provider, a card with a `value` has no group. Membership stops at
* a layer boundary, so a card in a layer opened from a member is not a member.

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.

Non-blocking: membership stops for any layer opened inside the group, not only one opened from a member. Suggested: "Membership stops at a layer boundary. A card in a layer opened inside the group is not a member."

This branch was successfully deployed

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

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants