Skip to content

[Component Audit] Item: a theme can restyle highlighted, selected, and disabled rows - #10073

Merged
cixzhang merged 9 commits into
mainfrom
night-watch-component-audit/Item/2026-11-05
Nov 5, 2026
Merged

cixzhang merged 9 commits into
mainfrom
night-watch-component-audit/Item/2026-11-05

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Theme authors can now restyle a highlighted, selected, or disabled row. Item painted those states (the active row of a menu or a picker, the chosen row, an unavailable row) but did not reflect them on its item theme target, so a theme could reach a row's density and alignment but not its state. The row now carries data-highlighted, data-selected, and data-disabled on the target, the same names CommandPaletteItem uses. A row that composes Item reflects the states it passes to Item: for example, ListItem reflects selected and disabled, and DropdownMenuItem reflects disabled. Nothing changes for people using a row: no style, behavior, or accessibility change.

Builders get Item docs that match the source: ref has the root element's type (the root follows as, so it is not always a div), className and style are listed, and xstyle has its standard description.

The rest of Item is unchanged and now proven in a browser: a new States story and fail-closed Chromium receipts cover each state's paint and attributes, the keyboard focus ring, hover on an enabled and a disabled row, density padding, first-line alignment, and a 320px viewport, in light, dark, Butter, and RTL.

Audit result

  • Package/component: core/Item (released in @astryxdesign/core under ./Item)
  • Mode: Night Watch whole-component audit, rubric 1.16.6
  • Base: f384e62f5c4606e053e1aa562fdb0779c566750c
  • Exact head: a5ea981c642b5588b363fe98d4e06cff849d4e60
  • Component contract: existing Item.spec.md (authority: current), unchanged. The record governs alignment (FR1 to FR8) and touch press (FR9); its FR7 "no new state" is about the align axis. Row state on the theme target is governed by architecture:component-theming-surface INV6. No observational backfill was prepared; the closed evidence inventory below maps the rest of the public surface.
  • Runtime change: three state keys added to the themeProps('item', …) call. No style, default, or behavior change; the root gains data attributes only.
Before After
Score 89.8 / C (1 open BLOCK, grade capped at C) 99.2 / A (0 open BLOCKs)
Distinct defects 1 BLOCK, 6 FIX 0 BLOCK, 0 FIX scored against Item
Sensitivity fix the 1 BLOCK, change nothing else → 95.6 / A —
Section W Before After State
§1 Accessibility 16 5 5 scored; native button or link action, one tab stop, focus ring on the row through :has(:focus-visible), native disabled, selection as aria-current on a role-less row
§2 Theming 14 3 5 scored; BLOCK fixed: state reflected on the item target (INV6)
§3 Public API 14 5 5 scored
§4 Behavior 12 5 5 scored; alignment, press, swipe, link and delegation paths covered by the existing suites
§5a Design, objective 6 5 5 scored; spacing, radius, type and motion tokens (see Needs Review 2 for the swipe settle curve, owned by spec:AST-057)
§5b Design, rendered 4 not measured 4 scored from 13 exact-head frames; a disabled row's start icon keeps full strength beside its dimmed text (Needs Review 1)
§6 Testing 8 4 5 scored
§7 Code health 8 5 5 scored; no Effect; the swipe gesture loads only for a row that has swipe actions
§8 Docs 8 4 5 scored
§9 i18n and RTL 5 5 5 scored; no strings of its own; RTL measured (first-line play function and the RTL States frame)
§10 Responsive and touch 5 4 5 scored; 320px frame added

Measured weight is 96 of 100 before (§5b not measured) and 100 after. §11 is not run for an existing core component.

Why the score moved: §5b is measured at 4 (Needs Review 1); the theme-target fix closes the §2 BLOCK (3→5) and lifts the C cap; the truncation test and the browser receipts close the §6 and §10 FIXes; the doc fixes close three §8 FIXes

Pre-fix score: scored from base source before any change. Night Watch records only the landed post-fix result in the score ledger, so the pre-fix score lives here.

Findings fixed

ID Finding Authority Fix and proof
T6 / INV6 (BLOCK) isHighlighted, isSelected, and isDisabled select Item's style objects, but the item target reflected only density and align, so a theme could not reach a row's state architecture:component-theming-surface INV6 ("selection, disabled, and interaction state are reflected as target capabilities through themeProps") themeProps('item', {density, align, highlighted, selected, disabled}) with the 'name' : null pattern of CommandPaletteItem and SegmentedControlItem; states: ['highlighted', 'selected', 'disabled'] in the theming docs. Red, then green: the new Item.test.tsx case fails at base ("Expected the element to have attribute") and passes with the fix; the theming guard passes
V3 (FIX) labelLines and descriptionLines had no test anywhere Item source and docs; architecture:component-test-sufficiency New Item.test.tsx case: one-line truncation on node content (which wraps by default) and the resolved clamp counts 3 and 2. It fails when the clamp count is dropped, when labelLines is ignored, when the multi-line overflow is dropped, and when the one-line ellipsis is dropped. The AlignFirstLine clamped frame proves two visible lines over a fixture that runs past two
V15 (FIX) No rendered evidence for state paint, the focus ring, hover, density padding, or a narrow viewport Item source; design:bidirectionality ItemAudit.a11y.chromium.spec.ts and the new States story (no visual-baseline tag, so the stable visual plan does not change)
R11 (FIX) No 320px evidence WCAG 1.4.10 320px ContactList frame: no sideways scroll, every row inside the viewport
X5 (FIX) The docs typed ref as React.Ref<HTMLDivElement>; the source is React.Ref<HTMLElement>, since the root follows as Item source Doc type corrected
X5b (FIX) className and style had no doc entry architecture:public-component-api INV15 Added
X18 (FIX) xstyle used a non-standard description Night Watch Doc Reviewer canonical wording Standard description

Needs Review

  1. Disabled row start content (owner decision). A disabled row dims its label, description, and end content to half opacity, but not its start content (an icon or avatar keeps full strength). No current record decides which slots dim, so this audit leaves it.
  2. Swipe settle curve (owned elsewhere). The swipe layer settles every close on a raw 200 ms ease-out. spec:AST-057 FR7 records this as an implementation gap, and open draft refactor(Item): swipe actions run on the interactive-transition driver #8344 moves the gesture to the shared transition driver. Not scored here.
  3. Row clicks from portals and role-based controls (owned elsewhere). The row's onClick ignores clicks on native controls only; open pull request fix(Item): the row's onClick ignores clicks from portals and role-based controls #9393 extends that. Not scored here.
  4. Selected and highlighted rows lose hover and press paint. styles.selected and styles.highlighted set a flat background after the interaction overlay, so a selected interactive row shows no hover or mouse-press overlay. design:user-states does not list Item in its pressed matrix, so no current record decides this.
  5. Neutral selection paint (token layer, known systemic). In Neutral light, a selected row (--color-accent-muted, rgb(241, 241, 241)) and a highlighted row (--color-overlay-hover, 5% black) look almost the same; in Neutral dark, --color-accent-muted (rgb(38, 38, 38)) equals the surface, so a selected row shows no fill (frames states-neutral-light, states-neutral-dark). Butter paints a distinct blue. The pair lives in the theme tokens, so it is not scored against Item; it affects every component that paints selection with --color-accent-muted in Neutral.
  6. Forced colors (authority gap). A selected row's fill disappears under forced-colors: active; the row keeps aria-current. No current repository record sets forced-colors requirements for Item (SegmentedControl uses Highlight), so this is recorded, not scored.
  7. Record follow-up. Item.spec.md could name the reflected states beside its alignment axis in a later owner-approved record change.

Evidence

  • Before, base f384e62: themeProps('item', {density, align}); the new state test fails; Item.doc.mjs types ref as HTMLDivElement and omits className and style; no browser receipt covers states, focus, hover, density, or 320px.
  • Theme-target fix, red then green: the new Item.test.tsx state case fails at base ("Expected the element to have attribute") and passes at the head.
  • After, exact head: CI run 42043189540 (attempt 2), all green, including Stable visual regression:
    • axe over the 14 Item stories: 0 violations;
    • 13/13 Chromium frames pass their sensor receipts in artifact pr-a11y-evidence-a5ea981 (sha256:c74b1f6fb27fd6de269bc161db47450008eae410df0bee80bebe0d8a5dce25f4), each bound to build a5ea981;
    • States: data-highlighted, data-selected, data-disabled match every row; a selected role-less row has aria-current="true"; disabled rows have a native disabled button, aria-disabled, half-opacity text, and no pointer events; the rest row paints --color-overlay-hover under the pointer and the disabled row paints nothing new;
    • keyboard: the first Tab stop is the first row's button, and the row draws a 2px solid outline (the theme's focus outline width);
    • padding: 4, 8 and 12 px block (compact, balanced, spacious), 8 px inline (12 px spacious);
    • AlignFirstLine: every row is first-line; the labelLines={2} label shows two lines of a fixture that takes three; the dir="rtl" case row is right-to-left;
    • RTL States frame and 320px ContactList: rows mirror and stay inside the viewport with no sideways scroll.
  • Visual acceptance: N/A. The runtime change adds data attributes only, so no rendered state changes; Stable visual regression passed at the exact head and the new story is outside the stable plan.

Closed evidence inventory

Surface Source Tests Consumer docs Rendered evidence Authority Result
Exports Item, ItemProps, ItemAlign, ItemDensity, swipe types Item/index.ts export checks in CI Item.doc.mjs — architecture:public-component-api INV1 reachable
Slots: marker, start, label, description, end Item.tsx Item.test.tsx slot and empty-slot suites props, anatomy States, ContactList, AlignFirstLine frames source pass
align (center, start, first-line) Item.tsx alignment suites; AlignFirstLine play function align AlignFirstLine frames component:Item FR1–FR8 pass
density padding Item.tsx — density CompactMenu, SpaciousRows, States frames source pass
labelLines, descriptionLines, layout Item.tsx new truncation test; inline-layout tests props AlignFirstLine clamped case source; component:Item FR6 pass after this audit's test
Actions: onClick, href, as link root, interactiveRef, parent role Item.tsx action, link, delegation and role suites; Item.nestedPress.test.tsx props States frames (button action, first Tab stop) family:navigation-destinations; component:Item FR9 pass (Needs Review 3)
isHighlighted, isSelected, isDisabled paint and ARIA Item.tsx new state test; selection and disabled tests props States frames INV6; source pass after this fix
item target, density, align, states Item.tsx theming guard; new state test theming targets every frame architecture:component-theming-surface INV6 pass after this fix
Focus ring focusOutline.stylex.ts via Item — — states-neutral-tab-* source pass
Hover and press paint interactionOverlay.stylex.ts via Item press suites — states-neutral-hover-rest-light, states-neutral-hover-disabled-light component:Item FR9 pass (Needs Review 4)
Swipe actions and panel targets ItemSwipeLayer.tsx, useSwipeAction.ts swipe suites; swipe browser specs swipeActions, swipeBehavior — spec:AST-057 pass (Needs Review 2)
ref, className, style, xstyle, DOM props Item.tsx ref and passthrough tests props (now complete) — INV15 pass
Narrow viewport Item.tsx — — contact-list-narrow-neutral-light WCAG 1.4.10 pass
FR10 eligibility report
{
  "schema": "astryx.audit-eligibility/v1",
  "component": "Item",
  "package": "core",
  "mode": "night-watch",
  "rubricVersion": "1.16.6",
  "repository": {
    "base": "f384e62f5c4606e053e1aa562fdb0779c566750c",
    "head": "a5ea981c642b5588b363fe98d4e06cff849d4e60"
  },
  "contract": {"id": "component:Item", "authority": "current", "changed": false},
  "inventory": {"closed": true, "rows": 13, "open": []},
  "unresolved": {
    "objective": [],
    "manual": [
      "which slots a disabled row dims",
      "hover and press paint on selected and highlighted rows",
      "forced-colors selection paint (no current authority)",
      "record follow-up: name the reflected states in component:Item"
    ],
    "ownedElsewhere": [
      "swipe settle curve (spec:AST-057 FR7 gap; open draft 8344)",
      "row clicks from portals and role-based controls (open PR 9393)"
    ]
  },
  "remediations": [
    {"id": "T6/INV6", "kind": "bug-fix", "evidence": "state test red at base, green at head"},
    {"id": "V3", "kind": "objective-test", "evidence": "truncation test kills four mutants"},
    {"id": "V15", "kind": "browser-evidence", "evidence": "ItemAudit receipts"},
    {"id": "R11", "kind": "browser-evidence", "evidence": "320px ContactList receipt"},
    {"id": "X5", "kind": "doc-drift", "evidence": "ref type"},
    {"id": "X5b", "kind": "doc-drift", "evidence": "className and style entries"},
    {"id": "X18", "kind": "doc-drift", "evidence": "xstyle description"}
  ],
  "approvals": {"specOwner": "success (no record change)"},
  "checks": "all green at a5ea981 (CI run 42043189540 attempt 2, pr-a11y, pr-rtl and Stable visual regression included)",
  "eligible": false,
  "reasons": ["spec:AST-029 is phase accepted; FR11 activation has not shipped", "the pull request changes the theme target surface"]
}

@vercel

vercel Bot commented Nov 5, 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 Nov 5, 2026 2:24pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 5, 2026
@cixzhang cixzhang added ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) ci:run-rtl Run the RTL suite on this PR; write access, next push (AST-030 FR12) labels Nov 5, 2026
@astracat-bot

astracat-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 5, 2026, 2:31 PM UTC

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · a5ea981

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
ContextMenuItem 25.8 kB (+38 B) · 6.1 kB CSS (0) — — · — · —
DropdownMenuItem 20.3 kB (+31 B) · 6.0 kB CSS (0) — — · — · —
Pagination 93.1 kB (+29 B) · 16.6 kB CSS (0) — — · — · —
23 more components
Component Size LoC Visual · A11y · RTL
ContextMenu 82.9 kB (+28 B) · 16.3 kB CSS (0) — — · — · —
BreadcrumbItem 71.5 kB (+27 B) · 11.3 kB CSS (0) — — · — · —
DropdownMenuCheckboxItem 21.1 kB (+27 B) · 6.4 kB CSS (0) — — · — · —
RadioListItem 56.8 kB (+27 B) · 9.5 kB CSS (0) — — · — · —
SelectorOption 19.3 kB (+27 B) · 5.8 kB CSS (0) — — · — · —
DropdownMenu 77.8 kB (+26 B) · 16.4 kB CSS (0) — — · — · —
DropdownMenuSubMenu 59.7 kB (+26 B) · 9.3 kB CSS (0) — — · — · —
ListItem 58.7 kB (+26 B) · 10.7 kB CSS (0) — — · — · —
DropdownMenuRadioItem 21.1 kB (+25 B) · 6.4 kB CSS (0) — — · — · —
MoreMenu 78.1 kB (+25 B) · 16.4 kB CSS (0) — — · — · —
PowerSearch 260.0 kB (+25 B) · 22.6 kB CSS (0) — — · — · —
TableCell 84.1 kB (+25 B) · 16.7 kB CSS (0) — — · — · —
lab/TransferListSelector 87.0 kB (+25 B) · 1.9 kB CSS (0) — — · — · —
lab/TransferList 79.9 kB (+24 B) · 1.7 kB CSS (0) — — · — · —
Selector 83.1 kB (+23 B) · 16.2 kB CSS (0) — — · — · —
Table 92.3 kB (+23 B) · 16.9 kB CSS (0) — — · — · —
CheckboxListItem 59.7 kB (+22 B) · 10.7 kB CSS (0) — — · — · —
Markdown 153.6 kB (+22 B) · 19.2 kB CSS (0) — — · — · —
lab/CommentThread 268.5 kB (+22 B) · 2.4 kB CSS (0) — — · — · —
Item · Storybook 15.9 kB (+21 B) · 5.3 kB CSS (0) 1,688 (+6) ✓ · ✓ · —
TableHeaderCell 83.7 kB (+21 B) · 16.5 kB CSS (0) — — · — · —
lab/Comments 273.6 kB (+20 B) · 2.5 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 234.0 kB (+20 B) · 454 B CSS (0) — — · — · —

Package size: @astryxdesign/core 6.57 MB packed (+145 B); no new dependencies.

API changes: core +0 · ~4 · −0

Committed API report behind this build: cli 9 rows, core 8 rows; run pnpm api:report.

4 API changes (advisory)
Package Where Signature Usage
~ core Theme targets · target item (Item) target item (Item) props [align, density] → target item (Item) props [align, density] states [disabled, highlighted, selected] defineTheme({components: {'item': {…}}})
~ core Public attributes · attr data-disabled attr data-disabled (theme reflection on 30 targets) → attr data-disabled (theme reflection on 31 targets) [data-disabled] { … }
~ core Public attributes · attr data-highlighted attr data-highlighted (theme reflection on 1 target) → attr data-highlighted (theme reflection on 2 targets) [data-highlighted] { … }
~ core Public attributes · attr data-selected attr data-selected (theme reflection on 14 targets) → attr data-selected (theme reflection on 15 targets) [data-selected] { … }

Touched components checked; add ci:run-visual to run the full suite.


Generated by PR Enrichment workflow | View full report

…he pointer onto the disabled row, and read the focus width from the theme; resolve private self-review findings
… tested, and the clamped label is proven in a browser
…and the clamped frame proves its fixture runs past two lines

@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, for wording only. The item target change itself follows the theming rule that a component reflects its state on its own target, and the new test fails before the fix and passes after it.

  • The changeset (.changeset/item-theme-states.md) and the PR description say rows that compose Item, such as list, menu and option rows, get all three states, but each row reflects only the states it passes to Item (ListItem gets selected and disabled, menu, radio-list and checkbox-list rows get only disabled, SelectorOption gets none, and no Core row sets highlighted), so please reword both to say which rows reflect which states.

Heavy CI has not run on this revision yet.

[Automated review]

@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.

Approved pending CI: CI found no room for this head ("CI is full"), so its build and test jobs have not run; re-running the CI jobs will run them.

The item theme target now reflects highlighted, selected and disabled rows, as the theming rule that state stays on the component's own target asks, and the new test fails before the fix and passes after it. The changeset and description now say which composing rows reflect which states, which resolves the earlier request.

[Automated review]

@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.

Approved pending CI: the required CI jobs are still running on this head.

The item theme target now reflects highlighted, selected and disabled rows, as the theming rule that state stays on the component's own target asks, and the new test fails before the fix and passes after it. The audit spec's direction fix since the last review is correct: its browser checks pass on this head, including the right-to-left case in the first-line story.

[Automated review]

@cixzhang
cixzhang merged commit 3d018fb into main Nov 5, 2026
108 of 111 checks passed
@github-actions
github-actions Bot deleted the night-watch-component-audit/Item/2026-11-05 branch November 6, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — a5ea981c Deployed Nov 5, 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) ci:run-rtl Run the RTL suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant