Skip to content

fix: remove dialog description warning when aria-describedby is optional#3862

Open
mixelburg wants to merge 1 commit intoradix-ui:mainfrom
mixelburg:fix/dialog-description-warning
Open

fix: remove dialog description warning when aria-describedby is optional#3862
mixelburg wants to merge 1 commit intoradix-ui:mainfrom
mixelburg:fix/dialog-description-warning

Conversation

@mixelburg
Copy link
Copy Markdown

Fixes #3855

Problem

When a Dialog is created without a DialogDescription component, a console warning fires:

Warning: Missing `Description` or `aria-describedby={undefined}` for {DialogContent}.

However, per the APG dialog pattern, aria-describedby is optional. There are legitimate reasons to omit it, especially when dialog content includes semantic structures (lists, tables, multiple paragraphs) that would be difficult to understand as a single unbroken string by screen readers.

Fix

  • aria-describedby is now only set on DialogContent when a DialogDescription component is actually rendered
  • DialogDescription registers itself with the Dialog context via useEffect on mount
  • The console warning for missing description is removed entirely
  • The aria-labelledby attribute (for DialogTitle) is unchanged — title remains required

Changes

  • DialogContextValue — added hasDescription: boolean and setHasDescription
  • Dialog root — creates hasDescription state, passes through context
  • DialogContentImpl — conditionally sets aria-describedby
  • DialogDescription — registers itself via useEffect
  • dialog.test.tsx — updated test expectation (no warning when no description)
  • All 8 existing tests pass

The ARIA APG dialog pattern specifies that aria-describedby is optional.
Previously, Dialog always set aria-describedby={descriptionId} and warned
when no Description component was rendered, causing false positive warnings
for valid dialog configurations without descriptions.

Now:
- aria-describedby is only set when a DialogDescription is rendered
- The console warning for missing description is removed
- DialogDescription registers itself via context on mount

Fixes radix-ui#3855
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 20, 2026

⚠️ No Changeset found

Latest commit: e1b8029

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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 component shouldn't warn when there's no description

1 participant