Repository navigation
test(a11y): Alert Dialog contract and AlertDialog binding - #7488
Conversation
ALERT_DIALOG_PATTERN encodes the APG Alert Dialog parts component:AlertDialog AR1 adopts: alertdialog role and name, aria-describedby to the message, modality, initial focus on the least destructive action (advisory: APG guidance adopted by the draft record), Escape closes, and a click beside the surface is inert (advisory: the record's rule). Top layer, inert page and focus restoration stay with the modal-dialog contract through Dialog. Fixtures open a native dialog through an invoker; the harness gains Escape and clickBeside (a pointer click just outside the subject's box). The AlertDialog binding has two modal states opened through an opener button. Stories through the shared renderer, CI step, README. Test-only.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsAlertDialog (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression44 of 448 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 24 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Approval waits on a maintainer decision: alertdialog.keys.escape gates CI as required, but no current record on main adopts Escape-closes for AlertDialog yet (AST-020 FR15 does not list it, and component:AlertDialog AR1 in #7464 arrives as a draft), so a maintainer needs to identify the governing current record or make the row advisory until AR1 is current. Independently of that, three small fixes are needed:
- Rename the Chromium binding test from
TreeList [...]toAlertDialog [...]so CI output and the evidence report name the right binding. - Cite the APG focus guidance verbatim from the modal dialog pattern's note (“it may be advisable to set focus on the least destructive action”) rather than the reworded alert-dialog quote.
- Make
clickBesiderefuse a point inside the subject's box, since a viewport-filling surface currently receives the click itself.
[Automated review]
| }); | ||
|
|
||
| for (const state of ALERT_DIALOG_BINDING_STATES) { | ||
| test(`TreeList [${state.id}] — ${state.summary}`, async ({page}) => { |
There was a problem hiding this comment.
This binding is AlertDialog, but CI output and the uploaded contract report list these runs as TreeList [modal-confirm] and TreeList [modal-action-loading]. AST-020 FR4 asks that a failure be understandable from the test name.
test(`AlertDialog [${state.id}] — ${state.summary}`, async ({page}) => {| const APG_FOCUS = apgReq( | ||
| 'When a dialog opens, focus moves to an element inside the dialog; if the dialog is limited to interactions that confirm or cancel an irreversible action, focus is set on the least destructive action.', | ||
| K, | ||
| ); |
There was a problem hiding this comment.
The published Alert Dialog page's keyboard section only points to the modal dialog pattern, whose note reads “it may be advisable to set focus on the least destructive action”. This text is attributed to the alertdialog page and says “focus is set on the least destructive action”, which reads as a requirement in every test title for the row. AST-020 FR4 and FR2 ask for the exact APG source, so consider citing the note verbatim:
const APG_FOCUS: ApgRequirement = {
standard: 'apg',
pattern: 'dialog-modal',
requirement:
'If a dialog contains the final step in a process that is not easily reversible, such as deleting data or completing a financial transaction, it may be advisable to set focus on the least destructive action, especially if undoing the action is difficult or impossible.',
url: 'https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/#keyboardinteraction',
};| }, | ||
| evidenceLayer: 'real-browser', | ||
| alsoNeeds: ['dom'], | ||
| enforcement: 'required', |
There was a problem hiding this comment.
On main, no current record adopts Escape-closes for AlertDialog: AST-020 FR15 adopts the role, accessible name, state and relationship properties, and Tab plus Enter or Space; component:Dialog leaves Escape to family:overlay-dismissal, whose FR7 leaves the close result to each member's own contract; and component:AlertDialog AR1 in #7464 is a draft. Under FR9 this row can be required only once a current record adopts it, so it needs a maintainer decision: identify that record, or keep the row advisory until AR1 is current.
| // A point outside the box but inside the viewport: above-left when | ||
| // there is room, else below-right. | ||
| const x = | ||
| box.x >= 8 | ||
| ? box.x - 4 | ||
| : Math.min(viewport.width - 2, box.x + box.width + 4); | ||
| const y = | ||
| box.y >= 8 | ||
| ? box.y - 4 | ||
| : Math.min(viewport.height - 2, box.y + box.height + 4); | ||
| await page.mouse.click(x, y); |
There was a problem hiding this comment.
When the subject fills the viewport (its box starts within 8 px of the top-left corner and reaches the bottom-right edge), both fallbacks land inside the box: in Chromium at 1280×720 a viewport-filling modal dialog received this click at (1278, 718) on the dialog itself, so the click-beside row would judge a click that was not beside the surface. No current AlertDialog state reaches this, but the harness should refuse rather than substitute:
if (x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.y + box.height) {
throw new Error('the subject fills the viewport; there is no point beside it to click');
}
await page.mouse.click(x, y);…tract # Conflicts: # .github/workflows/ci.yml # internal/a11y-spec/README.md # internal/a11y-spec/src/harness.ts # internal/a11y-spec/src/harness/chromium.ts
There was a problem hiding this comment.
Approval waits on a maintainer decision: alertdialog.keys.escape gates CI as required, but no current record on main adopts Escape-closes for AlertDialog (AST-020 FR15 does not list it, and component:AlertDialog is still draft), so a maintainer needs to identify the governing current record or keep the row advisory until AR1 is current. Independently of that, four small fixes are needed:
- Rename the Chromium binding test from
TreeList [...]toAlertDialog [...]so CI output and the evidence report name the right binding. - Per AST-021 FR6 and FR14, remove the two
AlertDialog.test.tsxassertions the binding now owns (alertdialog role, description link) or name their removal blocker, and list the moved and retained local tests in the description. - Cite the APG focus guidance verbatim from the Dialog (Modal) pattern's note (“it may be advisable to set focus on the least destructive action”), and the Escape text from that same page, instead of attributing reworded text to the Alert Dialog page.
- Make
clickBesiderefuse a point inside the subject's box, since a viewport-filling surface currently receives the click itself.
[Automated review]
…by assertions move to the binding; focus and Escape cite the Dialog (Modal) page verbatim; clickBeside refuses a point inside the subject
There was a problem hiding this comment.
This looks ready to approve: every row of the Alert Dialog contract now has current authority (the required Escape row rests on the maintainers' ruling recorded in the description), and the four fixes from the previous review are in — the Chromium test is named for AlertDialog, the duplicated local assertions are removed with a moved/retained ledger, the focus and Escape sources quote the Dialog (Modal) page verbatim, and clickBeside refuses a point inside the subject. CI's contract report for this revision passes the conforming fixture, fails all nine mutations, and passes both AlertDialog states. One follow-up outside this diff: when component:AlertDialog AR1 is made current, its verification map should name this binding in place of the two removed tests.
[Automated review]
…tract # Conflicts: # .github/workflows/ci.yml
There was a problem hiding this comment.
One small fix is needed before this can be approved: the Alert Dialog contract, binding and CI step otherwise look right, and CI's contract report for this revision passes the conforming fixture, fails all nine mutations and passes both AlertDialog states. The advisory alertdialog.dismissal.click-beside-is-inert row says it supports WCAG 2.2 3.2.2 and counts toward 3.2.2-on-input, but 3.2.2 only covers changing a control's setting, which a click beside the dialog is not (the package's button contract already makes this point), so per AST-020 FR1 please describe its WCAG outcome without that mapping, drop 3.2.2-on-input from its covers, and answer 3.2.2 with a full exemption instead. Optionally, in the same revision, open the dialog in the jsdom state cases as the Dialog binding does, and correct the description's test count (51, not 53).
[Automated review]
| wcagOutcome: | ||
| 'Supports WCAG 2.2 3.2.2 by keeping the question on screen until the user answers it; the binding record states the rule, so this row is advisory until it is current (AST-020 FR9).', | ||
| covers: ['3.2.2-on-input', 'apg-interaction'], |
There was a problem hiding this comment.
Required (AST-020 FR1). WCAG 2.2 3.2.2 covers changing the setting of a control, and its Understanding text, quoted in this package's button.ts 3.2.2 exemption, says activating a link or a button does not change a setting. A click beside the dialog changes no setting either, so naming 3.2.2 here and listing 3.2.2-on-input in covers maps the row to a success criterion that does not reach it; FR1 asks an APG-primary row to name the WCAG outcome it supports without inventing a success-criterion mapping. Suggested change, with which the contract's completeness tests still pass:
wcagOutcome:
'Keeps the question on screen until the user answers it (WCAG 2.2 Guideline 3.2, Predictable); no success criterion requires it, and the binding record states the rule, so this row is advisory until it is current (AST-020 FR9).',
covers: ['apg-interaction'],and answer 3.2.2 with a full exemption (no coversRemainderOnly):
'3.2.2-on-input': {
owner: 'the caller, for what its own handlers do',
verifiedBy: 'integration review of what a caller does with onAction',
reason:
"3.2.2 governs changing a control's setting; activating the alert dialog's buttons or clicking beside it is not one, so it does not reach this contract. What a caller does in response is the caller's.",
},| render: () => { | ||
| render(renderAlertDialogState(state)); | ||
| }, |
There was a problem hiding this comment.
Optional: these state cases never click the opener, so they check the closed <dialog> while the test name says “opened from a button”. The DOM result is the same today, but AST-009 FR10 asks that the tested state be the claimed state, and the Dialog binding opens first:
render: () => {
render(renderAlertDialogState(state));
openSurface();
},…CAG 3.2.2; 3.2.2 is a full exemption to the caller and composing page
There was a problem hiding this comment.
This looks ready to approve: the click-beside row no longer maps to WCAG 3.2.2 and 3.2.2 is now a full exemption, every row of the Alert Dialog contract has current authority (the required Escape row rests on the maintainers' ruling), and CI's contract report for this revision passes the conforming fixture, fails all nine mutations and passes both AlertDialog states. Nothing further is required; if you edit the description again, it still lists 3.2.2-on-input as “remainder only” and cites the draft record's FR1 for Escape, which the record states in FR2. The inline notes suggest optional hardening: find the message by its text and open the dialog in the jsdom state cases, add a narrow-viewport state so the advisory focus row would catch a lost autofocus target, and use the #aboutthispattern anchor the sibling contracts use.
[Automated review]
| ); | ||
| const APG_MODAL = apgReq( | ||
| "An alert dialog is a modal dialog that interrupts the user's workflow to communicate an important message and acquire a response.", | ||
| 'about-this-pattern', |
There was a problem hiding this comment.
Optional: the sibling switch and toggle-button contracts link this section as #aboutthispattern, the same space-free form as this file's #keyboardinteraction and #wai-ariaroles,states,andproperties; #about-this-pattern matches neither that form nor the section's own id (about).
const APG_MODAL = apgReq(
"An alert dialog is a modal dialog that interrupts the user's workflow to communicate an important message and acquire a response.",
'aboutthispattern',
);| const message = document.getElementById( | ||
| surface().getAttribute('aria-describedby') ?? '', | ||
| ); |
There was a problem hiding this comment.
Optional hardening: the message is found through the surface's own aria-describedby, so in this lane alertdialog.description.references-message cannot fail for a link aimed at the wrong element (the Chromium lane and the inline-path test in AlertDialog.test.tsx still catch it). Designating it by its text, as the Chromium spec does, makes this lane sensitive too, and calling openSurface() after render(...) in the state cases (L96–98) would make them check the opened state their names claim (AST-009 FR10):
// ALERT_DIALOG_MESSAGE from ./AlertDialog.a11y.states
const message = screen.getByText(ALERT_DIALOG_MESSAGE);|
|
||
| const story = (id: string) => `a11y-alertdialog--${id}`; | ||
|
|
||
| export const ALERT_DIALOG_BINDING_STATES = [ |
There was a problem hiding this comment.
Optional, worth doing before AR1 makes the focus row required: at the 1280 px viewport the Chromium lane uses, Cancel is the dialog's first focusable control, and Chromium's own showModal() focuses the first focusable control, so alertdialog.focus.least-destructive-first would still pass if Dialog's [data-autofocus] handling stopped working. At 640 px and below AlertDialog renders the action first (AlertDialog.tsx L244–246), so a narrow-viewport state would make that row discriminating.
…tract # Conflicts: # .github/workflows/ci.yml # internal/a11y-spec/README.md
There was a problem hiding this comment.
This looks ready to approve: the Alert Dialog contract and the AlertDialog binding match current authority (the required Escape row rests on the maintainers' ruling quoted in the description), and CI on this revision passes the conforming fixture, fails all nine mutations and passes both AlertDialog states. Nothing further is required. If you edit the description again, three details are stale: 3.2.2-on-input is now a full exemption rather than “remainder only”, the draft AlertDialog record states Escape in FR2 rather than FR1, and the pr-scope-touches.test.mjs floor is already on main.
[Automated review]
…tract # Conflicts: # .github/workflows/ci.yml # internal/a11y-spec/README.md
There was a problem hiding this comment.
This looks ready to approve: the Alert Dialog contract and the AlertDialog binding match current authority (the required Escape row rests on the maintainers' ruling quoted in the description), and on this revision the conforming fixture and both AlertDialog states pass in Chromium while all nine deliberate violations fail. Nothing further is required; this revision only merges main and leaves the contract, binding and CI step unchanged. If you edit the description again, it still lists 3.2.2-on-input as “remainder only” (it is now a full exemption), cites the draft AlertDialog record's FR1 for Escape (the record states it in FR2), mentions a pr-scope-touches.test.mjs change that is already on main, and leaves the retained “is a modal alertdialog” test out of the retained-tests list.
[Automated review]
What this proves
component:AlertDialogAR1 (the Alert Dialog adoption recorded in #7464 underspec:AST-020FR15) now has an executable contract and a binding. A screen-reader or keyboard user who triggers a consequential action gets: a surface announced as an alert dialog, named by its title and described by its consequence message, modal, opening with focus on the least destructive action (Cancel), closable with Escape, and not dismissed by a click on the dimmed page beside it.Test-only: no runtime, docs, or Changeset. Enforcement follows
spec:AST-020FR9: APG-required parts arerequired; which control takes initial focus (APG guidance) and the no-backdrop-dismissal rule (the record's own) areadvisoryuntil AR1 is current. Modal mechanics — top layer, inert page, focus entering after modal presentation and returning to the opener — are the modal-dialog contract's, proven once on Dialog, and exempted here to that owner.Expectations (AST-020 FR13)
alertdialog.role.exposedalertdialog.name.exposedalertdialog.description.references-messagealertdialog.modal.exposedalertdialog.focus.least-destructive-firstalertdialog.keys.escapealertdialog.dismissal.click-beside-is-inertExemptions:
1.1.1-non-text-content→ the binding component;1.3.1-info-and-relationships→ the binding component (remainder only);1.3.2-meaningful-sequence→ the binding component;1.3.5-identify-input-purpose→ not applicable;1.4.1-use-of-color→ the binding component and theme;1.4.3-contrast-minimum→ the binding component and theme;1.4.11-non-text-contrast→ the binding component and theme;2.1.1-keyboard→ the modal-dialog contract through the composed Dialog, and the button pattern (remainder only);2.1.2-no-keyboard-trap→ the modal-dialog contract through the composed Dialog;2.4.2-page-titled→ the page;2.4.3-focus-order→ the modal-dialog contract through the composed Dialog (remainder only);2.4.4-link-purpose→ not applicable;2.4.6-headings-and-labels→ the binding component and caller content (remainder only);2.4.7-focus-visible→ the Button binding and theme;2.4.11-focus-not-obscured→ the binding component;2.5.2-pointer-cancellation→ the button pattern;2.5.3-label-in-name→ the binding component;2.5.8-target-size→ the Button binding and theme;3.1.1-language-of-page→ the page;3.2.2-on-input→ the caller and composing page (remainder only);3.2.4-consistent-identification→ the composing page;3.3.1-error-identification→ not applicable;3.3.2-labels-or-instructions→ not applicable;4.1.2-name-role-value→ the binding component and the button pattern (remainder only);4.1.3-status-messages→ the caller and the assistive-technology verification record, spec:AST-009;apg-interaction→ the binding component's record (remainder only);forced-colors→ the binding component and theme;reduced-motion→ the binding component and theme;at-facing-strings→ the callerAuthority for the required Escape row
Maintainers' ruling (2026-10-13), path (a): current
spec:AST-020FR15 plus the owner's 2026-10-13 APG adoption approval govern. APG Alert Dialog inherits its keyboard model from Dialog (Modal), where Escape closes the dialog is a required part; AlertDialog ships it (component:AlertDialogFR1, verified), soalertdialog.keys.escapestaysrequired. The focus guidance and Escape text are quoted verbatim from the Dialog (Modal) page.Moved and retained local tests (AST-021 FR6, FR14)
Moved out of
AlertDialog.test.tsxinto the binding: "renders with alertdialog role" (→alertdialog.role.exposed) and "links description via aria-describedby" (→alertdialog.description.references-message). Retained: "links title via aria-labelledby" (the title link is a component contract the name row only partly covers), "renders title and description", and every behaviour test (Escape cancels, action does not close by itself, imperative API, inline path).Shape
internal/a11y-spec/src/patterns/alert-dialog.ts—ALERT_DIALOG_PATTERN, 7 expectations with WCAG and APG sources (APG Alert Dialog wording verified against the published pattern on 2026-10-13); every other checklist dimension exempted to a named owner.description.references-messageuses the harness'srelated('message')+references();focus.least-destructive-firstreadsrelated('cancel').alert-dialog.fixtures.ts— a native<dialog>an invoker opens withshowModal(); a small script answers Escape through thecancelevent and treats a click whose target is the dialog element as the backdrop click, like the component does (Dialog.tsx L617–626); every expectation has at least one violating twin (ALERT_DIALOG_MUTATIONS, 9 mutations).alert-dialog.jsdom.test.ts(10 cases; only the description reference is a DOM-layer claim) andalert-dialog.chromium.spec.ts.internal/a11y-spec/src/harness.ts+harness/{jsdom,chromium}.ts—KeygainsEscape; newclickBeside(subject): a pointer click just outside the subject's box (jsdom: unobservable, like the other real-browser methods);check.test.tsstub updated.packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.{states,renders,test}.tsxandAlertDialog.a11y.chromium.spec.ts— two modal states (confirm; action loading), each opened through an opener button so focus entry is the real one; the Chromium lane clicks the opener like the Dialog binding does.apps/storybook/stories/AlertDialogA11y.stories.tsx— oneno-visualstory per state throughrenderAlertDialogState..github/workflows/ci.yml— "Run Alert Dialog accessibility contract" step; scope throughpr-scope-touches.shfrom the base; runs when AlertDialog, Dialog, the harness, the stories, or the contract change.pr-scope-touches.test.mjstreats the consumer count as a floor (same change as the other open contract PRs).Source lines behind the binding facts
role="alertdialog"(inline:group),aria-labelledby/aria-describedby(AlertDialog.tsx L216–218); Dialogpurpose="form"→ backdrop click prevented, Escape allowed (L210; Dialog.tsx L109, L398, L617–626); Cancel initial focus (data-autofocushandling, AlertDialog.test.tsx L374 context).Ownership exclusions
ALERT_DIALOG_EXCLUSIONS: modal mechanics (MODAL_DIALOG_PATTERN through Dialog); theisInlinepreview (not an alert dialog;AlertDialog.test.tsx).Evidence