Repository navigation
AlertDialog: night watch component audit, 79.4 C to 89.6 B - #4887
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsAlertDialog (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
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.
We should not recommend prefixing with html unless it's used directly as the html title.
Usage of the theme target is correct here so if T28 is recommending against it it needs to be corrected.
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.
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.
|
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.
T28 — corrected. The rule read as a blanket ban, but its own citations say otherwise: #672 deliberately added 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.
Two things for you:
Night Watch — Component Auditor |
|
Merged as 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), 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 |
Night Watch component audit:
core/AlertDialogFull 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.jsonin 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 inpackages/core/srcandpackages/lab/src.AlertDialogis first. The next run can follow the same rule and takeAppShell, or a better tiebreak can be written into the role page.What moved
§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
AlertDialog.doc.mjs:24and the JSDoc atAlertDialog.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.fireEventclicks and static queries, while Escape-to-cancel, initial focus and focus restoration were all documented behaviors with no coverage. Added atAlertDialog.test.tsx:117-217.useImperativeAlertDialogis exported public API with zero tests, while the siblinguseImperativeDialogships its own test file. Six tests added atAlertDialog.test.tsx:220-299.Dialogalready focuses[data-autofocus]aftershowModal(), soAlertDialog.tsx:184-188now uses it. The two new assertions covering this are red without the change and green with it.bestPracticeshad 2 do's and 1 don't; the rule asks for at least 2 of each. Now 3 and 3.usage.anatomywas absent. Five parts documented.cancelLabelandisInlinewere 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/corerebuilt 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-4887branch, following the repo's existing asset-branch convention: before and after, namedAlertDialog__<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.
The unchanged surface, either side of the fix. The destructive variant at rest, light theme:
Focus-visible in all three themes, the evidence behind the focus findings in §1:
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):
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% darkscale(0.98), 67x32 to 65x31. Button archetype, so the transform is the right treatmentaria-busy="true", dimensions stable at 72x32. Fails the "never disabled" half, see Needs ReviewContrast, 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: 300pxwithoverflowY: autoand 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.
onActionandisActionLoadingversus the async-action convention (§3 P25, P10) — ruled: nit, left as is. API Conventions puts async work on buttons throughclickActionplususeTransition, and names the async twin{verb}Action. AlertDialog'sonActionandisActionLoadingare 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.Button) — open, againstButton.isActionLoadingreachesButton.isLoading, andButtoncomputesisDisabled || groupDisabled || (isLoadingState && !isInterruptible), so the action button becomes natively disabled mid-flight. Measured consequence inside the dialog:document.activeElementbecomesdocument.bodyin both light and dark.Buttonalready carries this as an open BLOCK (A11 in its ledger row), andisInterruptibleis documented for interruptible actions rather than fire-once ones, so a destructive confirm should not opt into it. The fix belongs inButton. Reported as advisory against AlertDialog and not scored against it, per the rubric's shared-module rule.titleshadows the native HTML attribute (§3 P33, NIT) — withdrawn: it was a false positive, and the guidance behind it was wrong.BasePropsalready omitstitlefromReact.HTMLAttributes(BaseProps.ts), soAlertDialogPropsis not shadowing anything and there is nothing to rename orOmit. The finding also leaned on guidance that should not have said what it said: thehtmlprefix 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 readBasePropsbefore flagging.themeProps('alert-dialog')on the element that also carries Dialog'sastryx-dialogtarget 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 addedmore-menuoverdropdown-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.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.document.bodybefore wrapping back into the modal — open, againstDialog. This reproduces on the plainDialogstory, so it isDialogor native<dialog>behavior rather than AlertDialog's, and it does not escape the modal. Noted so the next Dialog audit has the measurement.isInlinerendersrole="alertdialog"on a non-modal, always-present element — fixed, in the commit that follows the review. The inline path now rendersrole="group": the alertdialog role promises a modal interruption (focus trap, inert page, explicit dismissal) that this path does not provide, whilegroupstill supports the accessible name, soaria-labelledby/aria-describedbykeep the title and description attached. JSDoc, the.doc.mjsprop 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 buildandpnpm lint:strictall run locally before pushing.packages/clitheme-build tests failing onENOENT ... chdiragainst their temp directories. Confirmed pre-existing: the same 5 files failed the same way on the unmodified worktree atccb5ca9dc1before 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.main. One error was introduced mid-pass (vi.fn()as a default prop value trips@eslint-react/no-unstable-default-propsat the strict tier) and is fixed indb35bf5.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-exportsfor@astryxdesign/core: all clean.Re-run after the review commit:
AlertDialog.test.tsx31 passing (29 + the 2 new inline-role cases) andDialog.test.tsxgreen alongside it;lint:strict0 errors / 48 warnings, still themainbaseline;check:syncandcheck:changesetsclean. The two new cases fail against the previousrole="alertdialog"and pass with the fix.pnpm buildthenpnpm a11y:audit --components AlertDialogagainst 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 inpackages/coreorpackages/themesselects 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 tocomponent-scores.jsonwhen 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
onActionas 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