Skip to content

[6.x] Give modals a dialog role and accessible name - #15414

Merged
jasonvarga merged 2 commits into
statamic:6.xfrom
lazerg:fix/issue-15410-modal-dialog-role
Sep 7, 2026
Merged

[6.x] Give modals a dialog role and accessible name#15414
jasonvarga merged 2 commits into
statamic:6.xfrom
lazerg:fix/issue-15410-modal-dialog-role

Conversation

@lazerg

@lazerg lazerg commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This pull request fixes an issue where the Control Panel's modals are announced as plain groups of text rather than dialogs. Every confirmation modal inherits from ui/Modal, so deleting an entry, removing a nav page or dismissing the licensing alert gives a screen reader a Cancel/Delete choice with no indication that a dialog opened, and no name for it.

This was happening because the modal content is a bare <div data-ui-modal-content> with no role, no aria-modal and no aria-labelledby. The command palette avoids this because it uses reka-ui's DialogContent instead of this component.

This PR fixes it by adding role="dialog" and aria-modal="true" to the content element, and pointing aria-labelledby at the title the modal already renders. The title gets an id from useId(), shared with ModalTitle through a provide so both ways of setting a title work. aria-labelledby is left off when there's no title at all, and the attributes come before the fallthrough attrs so a consumer can still pass role="alertdialog".

Focus is already trapped by the FocusScope, so I left the inert suggestion out of this one.

Fixes #15410

@jasonvarga
jasonvarga merged commit fa490bf into statamic:6.x Sep 7, 2026
61 checks passed
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.

[6.x] ui/Modal has no dialog role or name, affecting every confirmation modal

2 participants