Skip to content

fix(modal): name the dialog from aria-labelledby - #31689

Open
akasakariko wants to merge 1 commit into
ionic-team:mainfrom
akasakariko:fix/modal-aria-labelledby
Open

akasakariko wants to merge 1 commit into
ionic-team:mainfrom
akasakariko:fix/modal-aria-labelledby

Conversation

@akasakariko

Copy link
Copy Markdown

Issue number: resolves #31622


What is the current behavior?

aria-labelledby set on ion-modal stays on the host, so the [role="dialog"] element in the shadow root has no accessible name. An ID reference only resolves against the tree of the element that carries it, so copying the attribute onto the wrapper does not name the dialog either

What is the new behavior?

  • ion-modal resolves the elements referenced by aria-labelledby and applies them to the dialog through element reflection (ariaLabelledByElements), which is not scoped to a tree
  • The documented pattern of labelling a modal with an ion-title in its content now names the dialog
  • The reflection is only applied when the reference resolves to at least one element, so an aria-label on the modal still names the dialog when aria-labelledby does not
  • The referenced elements are applied again when the modal is presented and when its slotted content changes

Does this introduce a breaking change?

  • Yes
  • No

Other information

Element reflection is Baseline 2025, so in older browsers the dialog is unnamed as it was before this change

Verification:

  • The new e2e test fails before the change with an axe aria-dialog-name violation and passes after it
  • npx playwright test src/components/modal/test/a11y passes on Mobile Chrome, Mobile Firefox and Mobile Safari
  • npx stencil test --spec passes (93 suites, 830 tests)
  • npx eslint and npx prettier --check pass on the changed files
  • The Chrome accessibility tree reports role=dialog with the name My modal title for a modal labelled with aria-labelledby

aria-labelledby set on ion-modal stayed on the host, so the dialog in the shadow root had no accessible name. An ID reference only resolves against the tree of the element that carries it, so the attribute cannot name the dialog with content authored in the light DOM

The referenced elements are now applied to the dialog through element reflection, which is not scoped to a tree. This names the dialog with an ion-title in the modal content, as documented

fixes ionic-team#31622
@akasakariko
akasakariko requested a review from a team as a code owner November 3, 2026 12:55
@akasakariko
akasakariko requested a review from ShaneK November 3, 2026 12:55
@vercel

vercel Bot commented Nov 3, 2026

Copy link
Copy Markdown

@akasakariko is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ion-modal - aria-labelledby on the host does not reach the dialog element

1 participant