Skip to content

Conversation

@tnyo43
Copy link

@tnyo43 tnyo43 commented May 17, 2025

resolve #337

Overview

Content of radix-ui/react-dialog requires Title to set its accessible title, otherwise it provides the following error: "DialogContent requires a DialogTitle for the component to be accessible for screen reader users." Also, we would like to set accessible description with Description.

In #337, they showed some workaround to avoid that error, but I prefer the library itself provides a way to solve the issue.

This change will set the title component if title and description properties of Command.Dialog is set.

Reproduction

I create a reproduction to see how it works.

main branch (fb4ea04) fix/no-title-error branch
with-main with-fix-no-title-error

@vercel
Copy link

vercel bot commented May 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cmdk-website ✅ Ready (Inspect) Visit Preview Jun 16, 2025 2:29am

<RadixDialog.Portal container={container}>
<RadixDialog.Overlay cmdk-overlay="" className={overlayClassName} />
<RadixDialog.Content aria-label={props.label} cmdk-dialog="" className={contentClassName}>
{title && <RadixDialog.Title hidden>{title}</RadixDialog.Title>}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RadixDialog.Title is set with hidden option, so its appearance doesn't change.

@tnyo43 tnyo43 marked this pull request as ready for review May 17, 2025 16:39
@elijaholmos
Copy link

can we get this merged? I'm running into this error as well.

@tnyo43 tnyo43 changed the title fix: set dialog title when provided to avoid Radix-ui error fix: set dialog title and description when provided to avoid Radix-ui error Jun 16, 2025
@tnyo43
Copy link
Author

tnyo43 commented Jun 16, 2025

Hi @pacocoursey 👋
I hope you're doing well. I wanted to follow up on this PR and kindly ask if you could take a look when you have a chance.
Your feedback would be really helpful, and I'm open to making any necessary changes.
Thanks so much for your time and effort!

@wdelmas
Copy link

wdelmas commented Jul 3, 2025

Feels like the project is not maintained anymore.
Do you guys know a substitute library ?

@supuwoerc
Copy link

I also encountered this error, and hope to accept this PR quickly~

@supuwoerc
Copy link

I also encountered this error, and hope to accept this PR quickly~我也遇到过这个错误,希望尽快接受这个PR ~

https://www.radix-ui.com/primitives/docs/components/dialog#title

https://www.radix-ui.com/primitives/docs/utilities/visually-hidden

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.

Rendering in a dialog causes console errors due to missing DialogTitle

4 participants