Skip to content

ui-kit: Surface, ActionCard, LinkPreviewCard and SearchResultCard render the whole card as div role=button #2762

Open

Description

@schlessera

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) and ActionCard (packages/ui-kit/src/decisions/ActionCard.tsx:317) → stretched title button: a native button on the title, a ::after covering 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) and SearchResultCard (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, LinkPreviewCard and SearchResultCard to their ruled patterns, with the phrasing-content diagnostic for the whole-button cards.
  • Migrate labelled Surface to the stretched title button.
  • Migrate label-less actionable Surface as 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.css rules).

Out of scope

Acceptance criteria

  • Each migrated control renders a native <button type="button"> with no own tabIndex (unless roving) and no Enter/Space handler, keeping tabStop/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 in packages/ui-*/src and tests that target this child's components are replaced with button selectors or data- 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/main

Contract 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

  1. added
    type: refactor
    area: ui-kit
    priority: p3
    needs: design
    on Oct 24, 2026
  2. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Design needed: what the stretched-button pattern does on a Surface that has no label.

    Already decided (ruling on #2586): an actionable Surface uses a stretched title button, a native <button> on the title with a ::after covering the card, no role on the card, and inner controls above the overlay. Still open: Surface's label is 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, SearchResultCard and labelled Surface are fully ruled and are not part of this question.

    Read first
    - packages/ui-kit/src/primitives/Surface.tsx:32-46 (SurfaceProps: label optional, children arbitrary, onClick), :132-156 (the current div role="button" root; the header row renders only when label is set, :148)
    - packages/ui-kit/src/primitives/Surface.tsx:7-31 (doc comment, see :27-31: an operable Surface must not hold an operable control; compose an inert Surface around an operable row)
    - packages/ui-kit/tests/visual/focus-frames.visual.tsx:52 (the label-less actionable case: <Surface radius={12} onClick={click}>Inspect the voyage</Surface>)
    - The maintainer ruling on brain-kit#2586 (comment 6338135188) and the D55 addendum text in it
    - docs/decisions/design-kit/components-and-interactions.md (D55: native icon and text actions; D27)
    - docs/decisions/design-kit/tokens-and-styles.md (D34: hit targets reach past the paint)
    - brain-kit#2586 (sub-epic) and its parent brain-kit#2576; this issue is its cards child
    
    The problem
    An actionable Surface must become native (no div role="button"). For a labelled Surface the ruled pattern puts a <button> on the label row and stretches it over the card. With no label there is no title element. Today the whole card is the button and its accessible name is the text content of its children ("Inspect the voyage"), which may contain anything.
    
    Design: answer each
    1. For an actionable Surface with no label, which of these does the kit do:
       (a) the whole Surface becomes a <button> (the whole-button card pattern), restricting children to phrasing content with a development diagnostic, as LinkPreviewCard does;
       (b) the stretched button wraps or sits on the first child, or on an invisible element, with an accessible name taken from somewhere specified;
       (c) an actionable Surface requires a label (a type-level and/or development-diagnostic rule), so the label-less case is migrated at its call sites;
       (d) something else, justified.
    2. What is the accessible name in the chosen answer, and where does it come from?
    3. What happens to the focus-frames test case at :52: does it keep its pixels and focus frame?
    4. If the answer changes SurfaceProps (a new required prop, or a narrowed children type), say so explicitly: that is a supported-API change that must be classified before code.
    
    Requirements to hold
    - No div/span role="button"; native <button type="button"> only; a button never contains interactive content.
    - Pixels of every existing Surface story and visual baseline are unchanged in both themes; the 44px reach (D34) holds.
    - Readable and operable at 320px.
    - Disabled rule from the ruling: focusable, announced (aria-disabled), activation ignored.
    - No new motion, no new visual treatment unless the answer is (d) and says why.
    
    Deliverable
    A comment on this issue: the chosen option with its reasoning, the accessible-name rule, the effect on SurfaceProps (none, or exactly what changes), and ASCII mocks of a label-less actionable Surface at 320px and 768px showing the focus frame. "Option (c): require a label, migrate the one existing call site" is an acceptable answer.
    
  3. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Design brief: actionable Surface with no label

    Answers 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-visible in tokens.css, and the #2586 ruling.

    Answer: (a). The label decides the pattern

    Surface Pattern Root element
    no onClick inert (unchanged) div
    onClick + label stretched title button (ruled) div, no role; <button> in the header row
    onClick, no label whole-button card (as for LinkPreviewCard) <button type="button">

    Why (a):

    • A label-less actionable Surface is exactly the D55-addendum case: "a card whose whole face is one action and holds only phrasing content … is a button." The label is the only part that sets a labelled card apart from a whole-face card, so it is the right switch.
    • It keeps today's name, tab stop and pixels with no new prop.
    • (b) needs an invisible button, and an invisible button needs a name source. That means a new ariaLabel-style prop, which is a contract addition, and a tab stop that sighted users can't see.
    • (c) adds a visible header row to the only label-less case, so the focus-frames baseline changes. That breaks "pixels unchanged". It is also a breaking type change (discriminated union).

    Accessible name rule

    • No label: the name is the button's text content, which is the children, exactly as today ("Inspect the voyage"). There is no aria-label and no new prop.
    • Label: the name is the label string only. meta and the body are not part of the name (the body sits outside the button).
    • Empty name: if a label-less actionable Surface renders no text (icon-only children, for example), a development diagnostic warns Surface: an actionable Surface without a label needs text content for its name. Production renders as-is.

    Content rule (label-less, actionable only)

    • The inner body div becomes a span with display:block, with the same inline styles, bk-focus-clip class and padding. The button resets UA styles (font: inherit; color: inherit; text-align: inherit; width: 100%; margin: 0; appearance: none), and keeps the existing border, background, radius and overflow on the root.
    • Children must be phrasing content. In development, the shared whole-button diagnostic (the same helper as 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, …).
    • Remedy text in the warning: Give the Surface a label (stretched title button), or compose an inert Surface around an operable row.
    • An inert Surface (no onClick) has no content restriction, as today.

    Focus frame: the same pixels in both patterns

    • Label-less: the <button> carries bk-row, so .bk-row:focus-visible (2px --bk-focus-ring, offset −2) paints on the card edge. This is byte-identical to today's div.bk-row.
    • Labelled (for reference, ruled): the title button's ::after covers the card (inset:0; border-radius:inherit), and the ring is painted on that ::after when the button is :focus-visible. It gives the same −2 card-edge frame, so Operable's ROW_RING still matches the card box.
    • Hover (--hv-bg) stays on the root in both patterns.

    Mocks (label-less, radius={12}, focused)

    320px:

      ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓   ← 2px focus ring, inset 2 (−2 offset)
      ┃                                  ┃      on the <button> itself
      ┃  Inspect the voyage              ┃   ← text content = accessible name
      ┃                                  ┃      button "Inspect the voyage"
      ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
       └─ whole card = hit area (≥44px tall: 12 + line + 12 pad, unchanged) ─┘
    

    768px (grid caps at 560px, as in the test):

      ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
      ┃  Inspect the voyage                                          ┃
      ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
      Tab order: …FilterRow "Ready" → [this card] → SlashPalette…
    

    Long text wraps inside the span (overflow-wrap:anywhere is inherited from the body). At 320px there is no horizontal scroll.

    Effect on SurfaceProps

    No type change. label?, children?: ReactNode and onClick? 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-frames test, which passes plain text. Classify this under contract-versioning.md before code (see Decision 1).

    The focus-frames case (:52)

    • <Surface radius={12} onClick={click}>Inspect the voyage</Surface> is valid as written. No call-site change.
    • Its pixels and focus frame stay the same: same box and same .bk-row ring. Only the element type changes.
    • The selector '[data-focus-inventory] [role="button"]' (the surface entry) must change, because a native button has no explicit role. Use '[data-focus-inventory] button.bk-row' or a data-surface hook. That falls under this issue's selector sweep.

    Browser assertions to add

    • Label-less actionable: the root tagName === "BUTTON", type="button", there is no role attribute and no tabindex, and accessible name === "Inspect the voyage".
    • Click, Enter and Space each fire onClick exactly once. Mutation: re-adding a keydown Enter handler gives 2 calls.
    • Labelled actionable: the root is a div with no role. getByRole("button", { name: "Route home" }) is inside the header row. Clicking the body (the Meter) fires once (it hits the ::after).
    • Diagnostic: a label-less actionable Surface with <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-frames and the Surface story visual baselines are unchanged in light and dark, at 320 and 1280.

    Known consequence

    When onClick flips between undefined and a function, a label-less Surface swaps between div and button, so React remounts its children and their local state resets. No current call site toggles it. Callers that need a stable tree should keep onClick set and guard inside the handler.

    Open decisions

    1. Classification of the content rule. Options: (a) a non-breaking documented-semantics change (diagnostic only, no type or runtime change, no affected call sites), shipped as a minor changeset that names it; or (b) a breaking change. Recommend (a). No published behavior changes for any valid current use, and the rule already follows from "a button never contains interactive content".
    2. Diagnostic for an empty name. The warning is proposed above. Accept it, or rely on axe in tests only? Recommend accept: it costs nothing in production and catches icon-only label-less cards.
  4. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Design brief (1/2): actionable Surface with no label

    Answers the design prompt. Read at main 1135899b: Surface.tsx, focus-frames.visual.tsx:52, Surface.stories.tsx (Interactive, Operable, StrongButStatic, Unlabelled), .bk-row:focus-visible in tokens.css, and the #2586 ruling.

    Answer: (a). The label decides the pattern

    Surface Pattern Root
    no onClick inert (unchanged) div
    onClick + label stretched title button (ruled) div, no role; <button> in the header row
    onClick, no label whole-button card (as for LinkPreviewCard) <button type="button">

    Why (a):

    • A label-less actionable Surface is the D55-addendum case: "a card whose whole face is one action and holds only phrasing content … is a button."
    • It keeps today's name, tab stop and pixels, and adds no new prop.
    • (b) needs an invisible button, and an invisible button needs a name source. That means a new ariaLabel-style prop (a contract addition) and a tab stop that sighted users can't see.
    • (c) adds a visible header row to the only label-less case, so the focus-frames baseline changes. It is also a breaking type change.

    Accessible name

    • No label: the name is the button's text content ("Inspect the voyage"), as today. There is no aria-label.
    • Label: the name is the label string only. meta and the body sit outside the button.
    • Empty name: a development diagnostic warns Surface: an actionable Surface without a label needs text content for its name.

    Content rule (label-less + actionable only)

    • The body div becomes span with display:block. The inline styles, bk-focus-clip and padding stay the same.
    • The button resets UA styles (font/color/text-align: inherit; width:100%; margin:0; appearance:none).
    • In development, the shared whole-button diagnostic (the same helper as 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, …).
    • Remedy text in the warning: Give the Surface a label (stretched title button), or compose an inert Surface around an operable row.
    • An inert Surface has no restriction.

    Focus frame: same pixels in both patterns

    • Label-less: the <button> carries bk-row, so .bk-row:focus-visible (2px --bk-focus-ring, −2 offset) paints on the card edge. This is identical to today's div.bk-row.
    • Labelled (reference): the title button's ::after covers the card (inset:0; border-radius:inherit), and the ring is painted on ::after while the button is :focus-visible. It gives the same frame, so Operable's ROW_RING holds on the card box.
    • Hover (--hv-bg) stays on the root.

    Part 2 covers the mocks, the props effect, the test case and the decisions.

  5. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Design brief (2/2): mocks, props, test case, decisions

    Mocks (label-less, radius={12}, keyboard-focused)

    320px:

    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓  ← 2px ring, −2 offset, on the <button>
    ┃                                  ┃
    ┃  Inspect the voyage              ┃  ← button "Inspect the voyage"
    ┃                                  ┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
      whole card = hit area (same box and height as today)
    

    768px (grid capped at 560px, as in the test):

    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
    ┃  Inspect the voyage                                        ┃
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
    Tab: … FilterRow "Ready" → [card] → SlashPalette …
    

    Long text wraps inside the span. At 320px there is no horizontal scroll.

    Effect on SurfaceProps

    No type change. label?, children?: ReactNode and onClick? 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.
    • The pixels and focus frame are unchanged: same box, same .bk-row ring. Only the element type changes.
    • The surface selector '[data-focus-inventory] [role="button"]' must change to '[data-focus-inventory] button.bk-row' or a data- hook. That is part of this issue's selector sweep.

    Browser assertions

    • Label-less actionable: the root is BUTTON with type="button", no role and no tabindex. Its name is "Inspect the voyage".
    • Click, Enter and Space each fire once. Mutation: a re-added Enter keydown handler gives 2 calls.
    • Labelled actionable: the root div has no role, and getByRole("button", { name: "Route home" }) is in the header row. Clicking the body fires once (it hits the ::after).
    • Diagnostic: <div> or <button> children warn. Text, <span>, <strong> and <Icon> don't. An inert Surface with a <div> doesn't.
    • focus-frames and Surface story baselines are unchanged in light and dark at 320 and 1280.

    Known consequence

    When onClick flips between undefined and a function, a label-less Surface swaps between div and button, and its children remount (local state resets). No current call site toggles it.

    Open decisions

    1. Classification of the content rule. Options: (a) non-breaking documented semantics (diagnostic only, no affected call sites), shipped as a minor changeset that names it; or (b) breaking. Recommend (a).
    2. Empty-name diagnostic for icon-only label-less cards. Accept it, or rely on axe only? Recommend accept: it costs nothing in production.
  6. added
    needs: decision
    needs: design
    contract
    and removed
    needs: design
    on Oct 24, 2026
  7. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    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.

  8. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    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.

  9. added
    breaking
    agent-ready
    and removed
    needs: decision
    needs: design
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-kitbreakingcontractpriority: p3type: refactor

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions