Skip to content

fix(a11y): unique modal title ids and close-time listener cleanup - #24

Merged
BrianGenisio merged 1 commit into
mainfrom
fix/a11y-d8-d10-d11-modal-hygiene
Aug 13, 2026
Merged

fix(a11y): unique modal title ids and close-time listener cleanup#24
BrianGenisio merged 1 commit into
mainfrom
fix/a11y-d8-d10-d11-modal-hygiene

Conversation

@BrianGenisio

Copy link
Copy Markdown
Contributor

Summary

Closes #19, #21, and #22 (D8, D10, D11 from the ChatCPT WCAG 2.2 AA audit).

Stacked or retained modal overlays no longer share id="modal-title", leave document keydown handlers attached after close, or ignore prefers-reduced-motion on in-content hash links.

Changes

Title ids follow the dropdown pattern: modal-title-${n} per instance, with aria-labelledby pointing at that id (omitted until a title exists).

Escape and focus-trap listeners attach in open() and detach in close(). Escape closes only the top of openModalStack, so a confirm dialog on top of settings does not dismiss both.

In-modal hash links use scrollIntoView({ behavior: 'auto' }) when prefers-reduced-motion: reduce. Default motion is unchanged.

Overlays still stay in the DOM after close, which is the existing reopen API. Unique ids make that safe. D9 (translated accessible names) is a separate contract change and is not in this PR.

Test plan

  • Two constructed modals have distinct title ids; aria-labelledby matches
  • Open A then B; Escape closes B only, then A
  • close() clears document listeners; open() reattaches
  • Help-modal TOC link uses smooth scroll by default and auto under reduced motion
  • axe on an open titled modal in light and dark (npm test)
  • Keyboard walkthrough on components/modal/test.html

ChatCPT does not hardcode modal-title. After merge, the app needs a submodule bump; no constructor API change here.

Give each instance its own modal-title id, attach Escape and focus-trap
listeners only while open, and skip smooth in-modal scrolling when
prefers-reduced-motion is set.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 91fa68d7-58bf-4b0d-8a1f-4be71d424ce8

📥 Commits

Reviewing files that changed from the base of the PR and between d21d15d and a17e029.

📒 Files selected for processing (3)
  • components/modal/README.md
  • components/modal/modal.js
  • tests/modal-a11y.spec.js

Comment @coderabbitai help to get the list of available commands.

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][D8] Every modal reuses id=modal-title

1 participant