Repository navigation
Description
Context
Part of #2586 (sub-epic under #2576). The maintainer ruling (2026-10-22) makes every actionable kit control a native <button type="button">: no div/span role="button", no own tabIndex (unless roving) and no hand-written Enter/Space handler. A button never contains interactive content. Disabled actionable controls stay focusable and announced (aria-disabled), and ignore activation. That shares #1474's ariaDisabled focus and announcement, but not its activation: #1474's ariaDisabled Button forwards the tap to the caller's onClick so it can explain, whereas these controls print their reason (why, blockedWhy) and ignore the tap. The difference is intentional per the ruling's own wording ("activation is ignored", "inert on activation").
Guide html/html: "DO use <button> for triggered actions (JS, Modals, Forms) … Set type="button" for non-submit buttons".
Cards, decided per card by the ruling:
Surface(packages/ui-kit/src/primitives/Surface.tsx:132-156) andActionCard(packages/ui-kit/src/decisions/ActionCard.tsx:317) → stretched title button: a native button on the title, a::aftercovering the card, no role on the card; inner links and buttons sit above the overlay (position: relative; z-index).LinkPreviewCard(packages/ui-kit/src/blocks/LinkPreviewCard.tsx:133) andSearchResultCard(packages/ui-kit/src/evidence/SearchResultCard.tsx:174) → whole-button card: the whole card is a<button>, content is phrasing-only (spans styled as blocks), and a development diagnostic flags interactive or flow children.
Maintainer decision (2026-10-24)
The maintainer approved option A, breaking classification, and the empty-name development warning:
- A labelled actionable Surface retains the ruled stretched title button; an unlabelled actionable Surface is a whole native button with phrasing-only content and no interactive descendants. An inert Surface remains unrestricted.
- The unlabelled button gets its accessible name from its text content; a labelled title button is named by its label. Add a development warning for an empty accessible name and the shared whole-button diagnostic for interactive or flow descendants. Production does not throw or filter children because of these diagnostics.
- No prop shape change: label remains optional and children remains ReactNode. Preserve the focus-frames example, pixels and focus ring. Document that toggling an unlabelled Surface between clickable and inert changes the root element and remounts children, resetting their local state.
- Classify the narrowed content semantics as breaking, explicitly approved here; ship a minor changeset naming the restriction while pre-1.0. The design comments supply implementation details subject to this ruling.
Scope
- Migrate
ActionCard,LinkPreviewCardandSearchResultCardto their ruled patterns, with the phrasing-content diagnostic for the whole-button cards. - Migrate labelled
Surfaceto the stretched title button. - Migrate label-less actionable
Surfaceas the approved whole-button pattern, including its content and accessible-name diagnostics. - Replace selectors that target these cards by role (including
packages/ui-kit/src/tokens.cssrules).
Out of scope
- The kit
Button(ui-kit: Button renders a div with role=button instead of a native button #1474) andDisclosure(ui-kit: Disclosure hand-rolls a toggle button instead of rendering details/summary #2584). - Elements with roles other than
button(tabs, radios, options). - Visual changes. Pixels stay as they are in both themes.
- The Composer textarea's IME handling (ui-kit: Composer shortcuts send or stop during IME composition #1810).
- A new required Surface prop; the approved design retains the existing prop shapes.
Acceptance criteria
- Each migrated control renders a native
<button type="button">with no owntabIndex(unless roving) and no Enter/Space handler, keepingtabStop/roving behaviour. Activation fires once per click, Enter or Space. - Disabled states (where the component has one) stay focusable, announce
aria-disabled, and ignore click, Enter and Space. -
[role="button"]selectors inpackages/ui-*/srcand tests that target this child's components are replaced withbuttonselectors ordata-hooks. - A real-browser test per migrated component asserts the native element and single activation, and fails on the current tree. A mutation that re-adds a manual Enter handler shows double activation. Record both runs in the PR.
- Visual baselines are unchanged in both themes, and every 44px reach assertion (D34) passes.
- Inner links and buttons inside stretched-button cards stay independently clickable and focusable above the overlay; the card itself has no role.
- The whole-button cards' diagnostic fires for interactive or flow children and not for phrasing content.
- Label-less actionable Surface follows the approved whole-button pattern, preserves the focus-frames case, warns in development for an empty accessible name, and documents the root-swap child-state reset when clickability changes.
Verification
node scripts/visual.mjs
bun run test packages/ui-kit packages/ui-react
bun run typecheck
bun run lint
bun run check:pr --base origin/mainContract impact
- The phrasing-only content requirement for an unlabelled actionable Surface is a breaking documented-semantics restriction, explicitly approved by the maintainer. Existing prop shapes remain unchanged. Apply contract and breaking, use a CONTRACT: commit and a same-commit authoritative contract update, and a minor changeset naming the restriction while pre-1.0 under docs/decisions/contract-versioning.md.
- Update the D55 decision record with the selected unlabelled Surface pattern and diagnostics.
- Published behavior changes require a changeset for @schlessera/brain-ui-kit, plus @schlessera/brain-ui-react where changed.
2026-10-24: filed from #2586 when it became a sub-epic, following the ruling's suggested split.
2026-10-24 maintainer ruling: approved A + breaking + warning; incorporated the unlabelled whole-button pattern, accessible-name/content diagnostics, unchanged prop shapes and known remount consequence. The decision is resolved.
Activity
schlessera commentedon Oct 24, 2026
Design needed: what the stretched-button pattern does on a
Surfacethat has no label.Already decided (ruling on #2586): an actionable
Surfaceuses a stretched title button, a native<button>on the title with a::aftercovering the card, no role on the card, and inner controls above the overlay. Still open:Surface'slabelis optional and its children are arbitrary, so an actionable Surface without a label has no title to carry the button, and the kit already uses that case. The code cannot settle this. It is a judgment about what the user tabs to, what a screen reader announces, and what the card's face looks like.ActionCard,LinkPreviewCard,SearchResultCardand labelledSurfaceare fully ruled and are not part of this question.schlessera commentedon Oct 24, 2026
Design brief: actionable
Surfacewith no labelAnswers the design prompt. Read at main
1135899b:Surface.tsx(props, doc comment, root),focus-frames.visual.tsx:52,Surface.stories.tsx(Interactive,Operable,OperableToned,StrongButStatic,Unlabelled),.bk-row:focus-visibleintokens.css, and the #2586 ruling.Answer: (a). The label decides the pattern
onClickdivonClick+labeldiv, no role;<button>in the header rowonClick, nolabelLinkPreviewCard)<button type="button">Why (a):
ariaLabel-style prop, which is a contract addition, and a tab stop that sighted users can't see.focus-framesbaseline changes. That breaks "pixels unchanged". It is also a breaking type change (discriminated union).Accessible name rule
"Inspect the voyage"). There is noaria-labeland no new prop.labelstring only.metaand the body are not part of the name (the body sits outside the button).Surface: an actionable Surface without a label needs text content for its name. Production renders as-is.Content rule (label-less, actionable only)
divbecomes aspanwithdisplay:block, with the same inline styles,bk-focus-clipclass and padding. The button resets UA styles (font: inherit; color: inherit; text-align: inherit; width: 100%; margin: 0; appearance: none), and keeps the existingborder,background,radiusandoverflowon the root.LinkPreviewCard/SearchResultCard) warns on interactive descendants (a[href],button,input,select,textarea,[tabindex],[contenteditable], a nested actionable Surface) and on flow elements (div,p,ul,ol,h1–h6,section,table, …).Give the Surface a label (stretched title button), or compose an inert Surface around an operable row.onClick) has no content restriction, as today.Focus frame: the same pixels in both patterns
<button>carriesbk-row, so.bk-row:focus-visible(2px--bk-focus-ring, offset −2) paints on the card edge. This is byte-identical to today'sdiv.bk-row.::aftercovers the card (inset:0; border-radius:inherit), and the ring is painted on that::afterwhen the button is:focus-visible. It gives the same −2 card-edge frame, soOperable'sROW_RINGstill matches the card box.--hv-bg) stays on the root in both patterns.Mocks (label-less,
radius={12}, focused)320px:
768px (grid caps at 560px, as in the test):
Long text wraps inside the span (
overflow-wrap:anywhereis inherited from the body). At 320px there is no horizontal scroll.Effect on
SurfacePropsNo type change.
label?,children?: ReactNodeandonClick?keep their shapes. The children restriction is enforced by a development diagnostic only, not by the type system.It is still a documented semantic tightening: a label-less operable Surface may no longer hold flow content. Today's doc comment only forbids nested controls. A repo search found no production call site of a label-less actionable Surface; the only one is the
focus-framestest, which passes plain text. Classify this undercontract-versioning.mdbefore code (see Decision 1).The
focus-framescase (:52)<Surface radius={12} onClick={click}>Inspect the voyage</Surface>is valid as written. No call-site change..bk-rowring. Only the element type changes.'[data-focus-inventory] [role="button"]'(thesurfaceentry) must change, because a native button has no explicit role. Use'[data-focus-inventory] button.bk-row'or adata-surfacehook. That falls under this issue's selector sweep.Browser assertions to add
tagName === "BUTTON",type="button", there is noroleattribute and notabindex, andaccessible name === "Inspect the voyage".onClickexactly once. Mutation: re-adding akeydownEnter handler gives 2 calls.divwith no role.getByRole("button", { name: "Route home" })is inside the header row. Clicking the body (theMeter) fires once (it hits the::after).<div>or<button>children warns once. Text,<span>,<strong>and<Icon>children don't warn. An inert Surface with a<div>doesn't warn.focus-framesand theSurfacestory visual baselines are unchanged in light and dark, at 320 and 1280.Known consequence
When
onClickflips between undefined and a function, a label-less Surface swaps betweendivandbutton, so React remounts its children and their local state resets. No current call site toggles it. Callers that need a stable tree should keeponClickset and guard inside the handler.Open decisions
breakingchange. Recommend (a). No published behavior changes for any valid current use, and the rule already follows from "a button never contains interactive content".schlessera commentedon Oct 24, 2026
Design brief (1/2): actionable
Surfacewith no labelAnswers the design prompt. Read at main
1135899b:Surface.tsx,focus-frames.visual.tsx:52,Surface.stories.tsx(Interactive,Operable,StrongButStatic,Unlabelled),.bk-row:focus-visibleintokens.css, and the #2586 ruling.Answer: (a). The label decides the pattern
onClickdivonClick+labeldiv, no role;<button>in the header rowonClick, nolabelLinkPreviewCard)<button type="button">Why (a):
ariaLabel-style prop (a contract addition) and a tab stop that sighted users can't see.focus-framesbaseline changes. It is also a breaking type change.Accessible name
"Inspect the voyage"), as today. There is noaria-label.labelstring only.metaand the body sit outside the button.Surface: an actionable Surface without a label needs text content for its name.Content rule (label-less + actionable only)
divbecomesspanwithdisplay:block. The inline styles,bk-focus-clipand padding stay the same.font/color/text-align: inherit; width:100%; margin:0; appearance:none).LinkPreviewCard/SearchResultCard) warns on interactive descendants (a[href],button,input,[tabindex],[contenteditable], a nested actionable Surface) and on flow elements (div,p, lists, headings,table, …).Give the Surface a label (stretched title button), or compose an inert Surface around an operable row.Focus frame: same pixels in both patterns
<button>carriesbk-row, so.bk-row:focus-visible(2px--bk-focus-ring, −2 offset) paints on the card edge. This is identical to today'sdiv.bk-row.::aftercovers the card (inset:0; border-radius:inherit), and the ring is painted on::afterwhile the button is:focus-visible. It gives the same frame, soOperable'sROW_RINGholds on the card box.--hv-bg) stays on the root.Part 2 covers the mocks, the props effect, the test case and the decisions.
schlessera commentedon Oct 24, 2026
Design brief (2/2): mocks, props, test case, decisions
Mocks (label-less,
radius={12}, keyboard-focused)320px:
768px (grid capped at 560px, as in the test):
Long text wraps inside the span. At 320px there is no horizontal scroll.
Effect on
SurfacePropsNo type change.
label?,children?: ReactNodeandonClick?keep their shapes. The children rule is enforced by a dev diagnostic only. It is still a documented semantic tightening: a label-less operable Surface may no longer hold flow content. Today's doc comment only forbids nested controls. A repo search found no production call site of a label-less actionable Surface; the only one is the test. Classify this before code (Decision 1).focus-frames.visual.tsx:52<Surface radius={12} onClick={click}>Inspect the voyage</Surface>is valid as written. No call-site change..bk-rowring. Only the element type changes.surfaceselector'[data-focus-inventory] [role="button"]'must change to'[data-focus-inventory] button.bk-row'or adata-hook. That is part of this issue's selector sweep.Browser assertions
BUTTONwithtype="button", noroleand notabindex. Its name is"Inspect the voyage".keydownhandler gives 2 calls.divhas no role, andgetByRole("button", { name: "Route home" })is in the header row. Clicking the body fires once (it hits the::after).<div>or<button>children warn. Text,<span>,<strong>and<Icon>don't. An inert Surface with a<div>doesn't.focus-framesandSurfacestory baselines are unchanged in light and dark at 320 and 1280.Known consequence
When
onClickflips between undefined and a function, a label-less Surface swaps betweendivandbutton, and its children remount (local state resets). No current call site toggles it.Open decisions
breaking. Recommend (a).schlessera commentedon Oct 24, 2026
2026-10-24 triage at main
77f35ef1ba34e4fab7092ada5362ae799852ea24: Folded the later proposal into the current prerequisite brief without approving it. Retained needs: decision for the public content-semantics classification and restored needs: design for the unapproved label-less interaction. Existing prompt remains usable; no duplicate design prompt or semantic waiver is posted.schlessera commentedon Oct 24, 2026
Decision (maintainer, 2026-10-24): Approved A + breaking + warning. An unlabelled actionable Surface becomes a whole native button, named by its text content, with phrasing-only children and no nested controls. Keep the ruled stretched title button for labelled cards. Add development warnings for an empty accessible name and interactive/flow descendants, with no production rejection or prop-shape change. Preserve existing pixels/focus frames and document that toggling clickability remounts children and resets local state. The content restriction is an explicitly approved breaking semantic change, shipped in a pre-1.0 minor with a changeset naming it. All decision questions are resolved; update D55 and the contract during implementation.