Skip to content

fix(dialog): only set aria-describedby when a Description is rendered#4013

Open
momomuchu wants to merge 1 commit into
radix-ui:mainfrom
momomuchu:fix/dialog-dangling-aria-describedby-3007
Open

fix(dialog): only set aria-describedby when a Description is rendered#4013
momomuchu wants to merge 1 commit into
radix-ui:mainfrom
momomuchu:fix/dialog-dangling-aria-describedby-3007

Conversation

@momomuchu

Copy link
Copy Markdown

Dialog.Content always sets aria-describedby to a generated id, even when no Dialog.Description is rendered, leaving a dangling ARIA reference (WCAG 4.1.2) (#3007).

Dialog.Description now registers its presence through context, and DialogContentImpl only sets aria-describedby when a Description is actually mounted. An explicit user-provided aria-describedby still works and the missing-description dev warning is unchanged. Alert Dialog inherits the fix since it delegates to Dialog.Description.

Added a dialog.test.tsx case asserting no aria-describedby without a Description. It fails without the fix and passes with it. All dialog and alert-dialog tests pass, typecheck and lint clean.

Closes #3007

Fixes a dangling ARIA reference (WCAG 4.1.2) where Dialog.Content
always pointed aria-describedby at a generated id even when no
Dialog.Description was mounted. Dialog.Description now registers
its presence with context so Content only references the id when
there is an element for it to describe.

Fixes radix-ui#3007
@changeset-bot

changeset-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3fcf5f0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@radix-ui/react-dialog Patch
@radix-ui/react-alert-dialog Patch
radix-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

Dialog content points to a non-existent aria-describedby id even when Dialog description is not present

1 participant