Skip to content

AlertDialog: night watch component audit, 79.4 C to 89.6 B - #4887

Merged
cixzhang merged 4 commits into
mainfrom
night-watch-component-audit/AlertDialog/2026-08-11
Aug 11, 2026
Merged

cixzhang merged 4 commits into
mainfrom
night-watch-component-audit/AlertDialog/2026-08-11

Conversation

@cixzhang

@cixzhang cixzhang commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Night Watch component audit: core/AlertDialog

Full rubric pass (Component Audit Rubric v1.2), then fixes, then a second pass to prove the fixes worked. Audited at ccb5ca9dc1.

Score: 79.4 (C) before, 89.6 (B) after. Open BLOCKs: 3 before, 0 after.

Why this component

The ledger (component-scores.json in the wiki) holds 5 rows, all from one calibration exercise: Badge, Button, SideNav, TextInput, Tooltip. Selection order is never-audited first, then oldest-audited, then lowest-scoring. That leaves roughly 137 never-audited components tied at the first step, and the wiki does not break that tie, so I broke it alphabetically across the live roster in packages/core/src and packages/lab/src. AlertDialog is first. The next run can follow the same rule and take AppShell, or a better tiebreak can be written into the role page.

What moved

Section W Before After Why
§1 Accessibility 16 4.0 4.5 APG pattern named; initial focus pinned
§2 Theming 14 4.5 4.5 unchanged
§3 Public API 14 4.0 4.0 unchanged, the naming question is left as a decision
§4 Behavior 12 4.0 4.5 overflow now demonstrated and measured
§5a Design, objective 6 5.0 5.0 unchanged
§5b Design, rendered 4 3.0 4.0 partial-coverage cap lifted
§6 Testing 8 2.5 4.5 two BLOCKs cleared, 13 cases to 29
§7 Code health 8 5.0 5.0 unchanged, zero Effects in both files
§8 Docs 8 3.0 4.5 BLOCK cleared, X3/X4/X10 fixed
§9 i18n and RTL 5 4.5 5.0 long-string story closes I18
§10 Responsive 5 3.5 4.0 long-content reflow and scrolling measured
Total 100 79.4 C 89.6 B

§6 and §8 carried the BLOCK ceilings (2 BLOCKs cap a section at 2.5, 1 caps it at 3), so clearing them is most of the move. The rest comes from evidence that did not exist before: three states that no story rendered, so nothing could see them.

Fixed

  1. §1 A2 / §8 X16 (BLOCK): the component implements the WAI-ARIA APG Alert Dialog pattern correctly, and named it nowhere. A2 requires the pattern to be named in the component's docs on a nightly or grading pass. Now named and linked in AlertDialog.doc.mjs:24 and the JSDoc at AlertDialog.tsx:103. Ownership note: no enforcer exists for this, so the rubric's tiebreak puts it in the section holding the file you would edit, which is §8.
  2. §6 V6 / V7 (BLOCK): no keyboard test and no focus test. The 13 existing cases were all fireEvent clicks and static queries, while Escape-to-cancel, initial focus and focus restoration were all documented behaviors with no coverage. Added at AlertDialog.test.tsx:117-217.
  3. §6 V3 (BLOCK): useImperativeAlertDialog is exported public API with zero tests, while the sibling useImperativeDialog ships its own test file. Six tests added at AlertDialog.test.tsx:220-299.
  4. §1 A5 (FIX): the docs promised "initial focus goes to the cancel button (least destructive action)". That was true only because Cancel happens to be the first focusable node in the footer. Nothing pinned it, so adding any focusable element ahead of it would have broken a documented accessibility guarantee silently. Dialog already focuses [data-autofocus] after showModal(), so AlertDialog.tsx:184-188 now uses it. The two new assertions covering this are red without the change and green with it.
  5. §8 X3 (FIX): bestPractices had 2 do's and 1 don't; the rule asks for at least 2 of each. Now 3 and 3.
  6. §8 X4 (FIX): usage.anatomy was absent. Five parts documented.
  7. §8 X10 / X12 (FIX): cancelLabel and isInline were documented props that no story exercised (9 of 11, 82%), and nothing rendered long text, so the a11y and RTL sweeps could not reach those states. Three stories added, taking prop coverage to 100%. This also closes the evidence half of §4 B10, §9 I18 and §10 R11.

Visual evidence

24 screenshots before, 31 after, captured by driving real Chromium with Playwright against local Storybook, with @astryxdesign/core rebuilt between the fix and the after pass. States: rest across all 7 stories, action hover, cancel hover, focus-visible, pressed, loading, custom cancel label, long content, inline, 320px, coarse pointer, and a 400px-tall viewport. Themes: neutral light, neutral dark, and y2k.

All 55 captures are on the assets/pr-4887 branch, following the repo's existing asset-branch convention: before and after, named AlertDialog__<variant>__<state>__<theme>.png. The pairs that carry the argument are below, and the measured evidence behind the §5b grade follows them.

Three states no story could reach before this change. New capability rather than a rendering change, so there is no before image for these.

Long content, scrolling Inline Custom cancel label
Long content in a scrolling AlertDialog Inline AlertDialog AlertDialog with a custom cancel label

The unchanged surface, either side of the fix. The destructive variant at rest, light theme:

Before After
AlertDialog delete variant at rest, before AlertDialog delete variant at rest, after

Focus-visible in all three themes, the evidence behind the focus findings in §1:

Light Dark y2k
Focus ring, light theme Focus ring, dark theme Focus ring, y2k theme

No visual regression. Every state captured in both passes is identical, at 0.00% of pixels changed, except two animation-timing artifacts: the loading spinner at 0.02% and the pressed transform at 0.09%. Nothing in this change was meant to alter rendering, and nothing did.

State-visual conformance matrix (against Design Conventions §Consistent State Representations):

State Representation claimed Token signature present Verdict
Hover, action and cancel Hovered, Overlay style alpha tint over the button's own base (rgba(0,0,0,0.05) light, rgba(255,255,255,0.05) dark), guarded by @media (hover: hover); 58.2% of pixels change light, 58.3% dark pass
Focus-visible Focused, Outline style 2px solid outline at 3px offset, present in light, dark and y2k; 14.2% of pixels change pass
Pressed Pressed scale(0.98), 67x32 to 65x31. Button archetype, so the transform is the right treatment pass
Loading Loading / Processing aria-busy="true", dimensions stable at 72x32. Fails the "never disabled" half, see Needs Review partial
Disabled, status, selected n/a the component has no such props n/a

Contrast, measured from the rendered pixels: title 17.93:1, description 7.81:1 in light and 6.00:1 in dark. All above the AA bar, so D7 is clean and nothing here is token-layer debt.

Reflow: 288px wide with no horizontal scroll at a 320px viewport, for both short and long content. At a 400px-tall viewport the dialog caps at maxHeight: 300px with overflowY: auto and the action button stays on screen, so R5 holds.

Adversarial pass (B12), all clean: rapid triple-click on the action does not double-fire, Escape mid-flight closes without stranding the pending action, cancel mid-flight does not get reopened by the late callback, the imperative hook survives show/hide/show, and the body scroll lock is released on close.

One honest limitation on §5b. I captured real pixels and analysed them numerically: per-pixel diffs, resolved colors, contrast ratios, geometry. I could not view the images. The judgment rows (D3 spacing rhythm, D15 proportion and density, D16 AI tells) are graded from that data rather than from someone looking, which is why §5b is 4 and not 5. Worth a human glance at the contact sheet before anyone treats the visual half as settled.

Needs Review — and how it was reviewed

Left alone in the fix pass because each needed a decision rather than a correction. @cixzhang ruled on five of them in this comment; the rulings are applied below and the status of each item is called out.

  1. onAction and isActionLoading versus the async-action convention (§3 P25, P10) — ruled: nit, left as is. API Conventions puts async work on buttons through clickAction plus useTransition, and names the async twin {verb}Action. AlertDialog's onAction and isActionLoading are callbacks, not transition actions, so this is a name collision with the convention rather than a violation of it. No change; not carried as an open finding.
  2. The action button disables while busy (§1 A11, root cause in Button) — open, against Button. isActionLoading reaches Button.isLoading, and Button computes isDisabled || groupDisabled || (isLoadingState && !isInterruptible), so the action button becomes natively disabled mid-flight. Measured consequence inside the dialog: document.activeElement becomes document.body in both light and dark. Button already carries this as an open BLOCK (A11 in its ledger row), and isInterruptible is documented for interruptible actions rather than fire-once ones, so a destructive confirm should not opt into it. The fix belongs in Button. Reported as advisory against AlertDialog and not scored against it, per the rubric's shared-module rule.
  3. title shadows the native HTML attribute (§3 P33, NIT) — withdrawn: it was a false positive, and the guidance behind it was wrong. BaseProps already omits title from React.HTMLAttributes (BaseProps.ts), so AlertDialogProps is not shadowing anything and there is nothing to rename or Omit. The finding also leaned on guidance that should not have said what it said: the html prefix is for props that are the native attribute (htmlName, htmlFor), not for a prop that merely reuses the name with its own meaning. API Conventions §HTML Attribute Collisions and rubric P33 are corrected, and P33 now says to read BaseProps before flagging.
  4. A second theme target on one node (§2 T28, NIT) — withdrawn: the usage is correct and the rule was wrong. themeProps('alert-dialog') on the element that also carries Dialog's astryx-dialog target is the sanctioned shape — a composition layer naming its own concept on the element that paints, exactly what fix(MoreMenu): add xdsClassName for theme targeting #672 did when it added more-menu over dropdown-menu. What fix(theme): xdsClassName for TimeInput and Tooltip, fix hardcoded fontSize #749 actually skipped was Tokenizer, an outer node wrapping several independently themed components. Rubric T28 is rewritten to draw that line, at v1.2.1.
  5. Touch target size (§1 A10, root cause in Button) — tracked in [Tracker] Responsive web — server-safe breakpoints, mobile components & gestures, RSC #4476, the Q3 2026 responsive-web tracker. Both footer buttons render 32x32 CSS px: clears the 24x24 WCAG 2.5.8 floor, no expansion toward 44px under a coarse pointer, measured at 390px with touch emulation. The measurement and this audit reference are recorded on the tracker, with a coarse-pointer target-size item added under Hover, touch & pointer behavior.
  6. One tab stop lands on document.body before wrapping back into the modal — open, against Dialog. This reproduces on the plain Dialog story, so it is Dialog or native <dialog> behavior rather than AlertDialog's, and it does not escape the modal. Noted so the next Dialog audit has the measurement.
  7. isInline renders role="alertdialog" on a non-modal, always-present element — fixed, in the commit that follows the review. The inline path now renders role="group": the alertdialog role promises a modal interruption (focus trap, inert page, explicit dismissal) that this path does not provide, while group still supports the accessible name, so aria-labelledby/aria-describedby keep the title and description attached. JSDoc, the .doc.mjs prop entry and the Inline story say so, and two tests cover it — both red without the change, green with it. No pixels change; the modal path is untouched.

Checks

pnpm test, pnpm build and pnpm lint:strict all run locally before pushing.

  • test: 9655 passing. 8 failures in 5 files, all in packages/cli theme-build tests failing on ENOENT ... chdir against their temp directories. Confirmed pre-existing: the same 5 files failed the same way on the unmodified worktree at ccb5ca9dc1 before any edit, with the count drifting between 8 and 9 across runs, which is what a temp-directory race looks like. Not related to this change.
  • build: clean, and it leaves the tree clean too.
  • lint:strict: 0 errors, 48 warnings, exactly the baseline on main. One error was introduced mid-pass (vi.fn() as a default prop value trips @eslint-react/no-unstable-default-props at the strict tier) and is fixed in db35bf5.
  • axe via pnpm a11y:audit --components AlertDialog: 0 violations across all stories, with no entries added to .github/a11y-baseline.json.
  • pnpm rtl:audit --filter AlertDialog: 0 fail, 0 surprise.
  • check:sync, check:changesets, check-use-client, verify-exports for @astryxdesign/core: all clean.

Re-run after the review commit: AlertDialog.test.tsx 31 passing (29 + the 2 new inline-role cases) and Dialog.test.tsx green alongside it; lint:strict 0 errors / 48 warnings, still the main baseline; check:sync and check:changesets clean. The two new cases fail against the previous role="alertdialog" and pass with the fix. pnpm build then pnpm a11y:audit --components AlertDialog against a freshly built Storybook: 0 violations across all 7 stories, Inline included, no new baseline entries. No screenshots for this one — the change is a single attribute, no rule in packages/core or packages/themes selects on [role] for either value, and the modal path renders exactly as before.

Ledger

Not written in this pass, by standing instruction: the entry is held until these fixes are on main. The complete post-fix entry is prepared and will be pushed to component-scores.json when this merges.

Updated after review: the entry will cite rubric v1.2.1, carry the T28 and P33 findings as withdrawn rather than open, record onAction as a nit, and link #4476 from the A10 row. Neither withdrawn finding was a BLOCK and neither drove a section anchor, so the scores above stand unchanged.

Night Watch — Component Auditor

…ancel

The component implements the WAI-ARIA APG Alert Dialog pattern correctly but
named it nowhere a reader could find it (rubric A2 / X16). Add the pattern and
its link to the docs and the JSDoc, add the missing anatomy block (X4), and a
second and third don't so bestPractices has at least two of each (X3).

The docs already promised 'initial focus goes to the cancel button'. That was
true only because Cancel happens to be the first focusable node in the footer;
nothing pinned it. Dialog already focuses [data-autofocus] after showModal(),
so use it (A5).
…issing stories

Tests went from 13 cases to 29. The old file was all fireEvent clicks and
static queries: Escape-to-cancel, initial focus and focus restoration were
documented behaviors with no coverage (V6 is BLOCK for interactive components,
V7 for overlays), and useImperativeAlertDialog was exported public API with no
test at all (V3).

The two data-autofocus assertions are red without the source fix in the
previous commit and green with it.

Stories: cancelLabel and isInline were documented props no story exercised
(9/11 = 82% prop coverage), and nothing rendered long text, so the a11y and RTL
sweeps could not see those states (X10, X12, and the evidence half of B10, I18,
R11).
vi.fn() as a default prop value trips @eslint-react/no-unstable-default-props
at the strict tier, which is the tier CI runs.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 11, 2026
@vercel

vercel Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
astryx Ignored Ignored Aug 11, 2026 2:14pm

Request Review

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

AlertDialog (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 146 -
Complexity N/A Medium (7) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang

cixzhang commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor Author

onAction

These are technically callbacks and not transition actions on the alert dialog. Not exactly an exception but an unfortunate collision for the API convention. Likely fine to leave as a nit.

title

We should not recommend prefixing with html unless it's used directly as the html title.

T28

Usage of the theme target is correct here so if T28 is recommending against it it needs to be corrected.

A10

Noted. This should be part of the responsive web work in Q3 milestone. Please update that issue with this audit reference and link the issue in the audit results.

isInline

We should adjust the role under isInline conditions.

role="alertdialog" promises a modal interruption — a focus trap, an inert
page behind it, and an explicit dismissal path. The isInline preview
renders a plain always-present div with none of that, so the role
misdescribed it to assistive tech.

The inline path now renders role="group", which supports the accessible
name, so the title and description stay attached through aria-labelledby
and aria-describedby. Docs, the doc.mjs prop entry and the Inline story
say so; two tests cover it (both red without the change).

Addresses the isInline ruling in review of #4887.
@cixzhang

Copy link
Copy Markdown
Contributor Author

All five rulings applied. Detail is folded into the Needs Review section of the description, which now carries the status of every item; summary here.

onAction — taken as a nit and closed. Recorded in the description as a name collision with the async-action convention rather than a violation of it, since these are callbacks and not transition actions. Nothing to change in the component, and it will not come back as an open finding in the ledger row.

title — this one got worse under inspection, in a good way: it was a false positive. BaseProps already omits title from React.HTMLAttributes, so AlertDialogProps never shadowed the native attribute and there was nothing to rename or Omit. The finding only existed because the guidance said to reach for html*. API Conventions §HTML Attribute Collisions now says the prefix is for props that are the native attribute (htmlName, htmlFor), and that a prop reusing the name with its own meaning keeps the semantic name. Rubric P33 matches, and adds "read BaseProps before flagging".

T28 — corrected. The rule read as a blanket ban, but its own citations say otherwise: #672 deliberately added more-menu over dropdown-menu so themes could reach it, and #749 skipped Tokenizer, an outer node wrapping several independently themed components. T28 now permits a composition layer naming its own concept on the element that paints, and forbids only the multi-component wrapper node. alert-dialog beside astryx-dialog is the sanctioned shape, so the finding is withdrawn rather than carried.

A10 — tracked on #4476: the 32x32 measurement and this audit reference are posted there, and a coarse-pointer target-size item is added to the tracker body under Hover, touch & pointer behavior. The issue is linked from the A10 row in the description, and the ledger row will link it too.

isInline — fixed in 40e2de0. The inline path renders role="group" instead of role="alertdialog": the alertdialog role promises a modal interruption — focus trap, inert page, explicit dismissal — that this path does not provide, while group still supports the accessible name, so the title and description stay attached through aria-labelledby/aria-describedby. JSDoc, the .doc.mjs prop entry and the Inline story say so. Two tests cover it, red before the change and green after. AlertDialog 31 tests and Dialog green, lint:strict at the main baseline of 0 errors / 48 warnings, and axe clean across all 7 stories against a freshly built Storybook, Inline included.

Two things for you:

  • The rubric change is versioned 1.2.1 — a patch, on the grounds that no weight, floor or severity moved, so scores stay comparable with 1.2. Two checks did change scope, so say if you would rather it were a minor and I will re-cut it.
  • The ledger entry is still held until this merges. It will cite v1.2.1, carry T28 and P33 as withdrawn, record onAction as a nit, and link [Tracker] Responsive web — server-safe breakpoints, mobile components & gestures, RSC #4476 from the A10 row. Neither withdrawn finding was a BLOCK or drove a section anchor, so the 89.6 (B) stands.

Night Watch — Component Auditor

@cixzhang
cixzhang enabled auto-merge (squash) August 11, 2026 14:22
@cixzhang
cixzhang merged commit ec85ba0 into main Aug 11, 2026
19 checks passed
@cixzhang

Copy link
Copy Markdown
Contributor Author

Merged as ec85ba0b6f, and the ledger entry is recorded: AlertDialog 89.6/B, mode N, rubric v1.2.1 — wiki commit 3ef4010, replacing the 79.4/C pre-fix row. 3 BLOCKs to 0, delta +10.2.

The row records the review, not just the score: T28 and P33 are marked withdrawn with the reason (rule defects, not component defects, both corrected in rubric v1.2.1), onAction is closed as a nit, the isInline role fix is noted against §1, and the A10 row links #4476. The three findings that remain open are attributed to Button and Dialog rather than to AlertDialog, per the shared-module rule.

One judgment call worth flagging, since it holds the score down: §1 stayed at 4.5 rather than going to 5 after the isInline fix. The remaining §1 findings are root-caused elsewhere and so are not scored here, but they still composite in this component, and no screen-reader pass was run. That is written into the section note so the next audit can disagree with it on the record.

Night Watch — Component Auditor

github-actions Bot added a commit that referenced this pull request Aug 11, 2026
@github-actions
github-actions Bot deleted the night-watch-component-audit/AlertDialog/2026-08-11 branch August 13, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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