Skip to content

fix(rules): aria-dialog-name identifies id-less dialogs by class and start tag #462 - #475

Merged
nc9 merged 1 commit into
mainfrom
fix/aria-dialog-name-462
Oct 6, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/aria-dialog-name-462

Conversation

@nc9

@nc9 nc9 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #462

What was wrong

a11y/aria-dialog-name listed an unnamed dialog as dialog#<id>, or as a bare dialog (or role name) when it had no id. On a page with several id-less dialogs, such as a Shopify theme's cart, menu and newsletter drawers, the report could not say which one lacked a name. The duplicate ids also collapsed into one finding wherever items are keyed by id.

The fix

  • Each unnamed dialog is listed by a selector-like handle, in the tag#id / tag.class style the other a11y rules already use (button-name, tabindex, empty-heading):
    • with an id, unchanged: dialog#cart for a native dialog, dialog#settings / alertdialog#confirm for an ARIA one;
    • without one: the tag and up to three classes, dialog.newsletter-popup, or div[role="dialog"].modal for an ARIA dialog.
  • Each item carries its start tag as snippet, via the shared fieldSnippet helper that a11y/autocomplete-tokens already uses (attributes only, capped at 200 characters, never outerHTML).
  • Dialogs of the same kind that share a handle get an ordinal from the second one on, in document order: dialog.drawer (2).
    • The ordinal counts named dialogs too, so naming the cart drawer does not turn the menu drawer's dialog.drawer (2) into dialog.drawer.
    • An ordinal never repeats an id already issued.
  • Check names, statuses and messages are unchanged. The rule page documents the handle, the snippet and the identity policy.

Identity across rescans

The item id is the finding's locator in the cloud merge (merge-core flattenChecks). It depends only on the markup, so the same page gives the same ids on every scan, and fixing one dialog leaves the others' ids alone (tested).

One-time effect, filed as #474: on a page that still has an unnamed dialog, the legacy bare dialog finding stays open as a carried finding beside the new id. That is because merge-core carries unmatched prior items while the page is still in the check's failing set. It resolves when the page's dialogs are all named. Any item-id change on a still-failing page does this, which is why it is filed separately.

Evidence (CLI from source, --http -f json --refresh, the issue's repro page)

Before:

{"name": "dialog-name", "status": "warn", "message": "1 native <dialog>(s) without accessible names", "items": [{"id": "dialog"}]}

After:

{"name": "dialog-name", "status": "warn", "message": "1 native <dialog>(s) without accessible names",
 "items": [{"id": "dialog.newsletter-popup", "snippet": "<dialog class=\"newsletter-popup\">"}]}

Tests

  • New packages/rules/tests/aria-dialog-name.test.ts (13 tests) covers:
    • the repro, dialog#id, class order and the three-class cap, and a bare dialog;
    • ordinals, partial remediation keeping ids, ordinal collisions with literal ids, and determinism;
    • named dialogs passing, and the snippet cap;
    • ARIA id-less handles, role#id, and the ten-item cap.
      8 of the 13 fail on main.
  • Green: aria-dialog-name, template-verdict-page-independence, noscript-content.
  • tsgo --noEmit clean in packages/rules (and the test file). oxlint clean. [email protected] check --strict passes.

Changelog suggestion

@nc9
nc9 marked this pull request as ready for review October 6, 2026 00:18
…start tag #462

An unnamed dialog without an id was reported as a bare "dialog", so a page
with several id-less drawers gave no way to tell which lacked a name. Items
now use the a11y rules' tag#id / tag.class handle (dialog.newsletter-popup,
div[role="dialog"].modal) with the start tag as a snippet, and keep dialog#id
and role#id when there is an id. Dialogs sharing a handle get an ordinal
counted over every dialog of the kind, so naming one does not renumber the
rest, and an ordinal never repeats an id already issued.

Closes #462

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/aria-dialog-name-462 branch from e11eff2 to 254ea8a Compare October 6, 2026 00:18
@nc9
nc9 merged commit e51ae6d into main Oct 6, 2026
14 checks passed
@nc9
nc9 deleted the fix/aria-dialog-name-462 branch October 6, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a11y/aria-dialog-name: id-less dialogs are reported as bare "dialog", no way to locate them

1 participant