cmdk icon indicating copy to clipboard operation
cmdk copied to clipboard

fix: set dialog title and description when provided to avoid Radix-ui error

Open tnyo43 opened this issue 8 months ago • 6 comments

resolve https://github.com/pacocoursey/cmdk/issues/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 https://github.com/pacocoursey/cmdk/issues/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 (https://github.com/pacocoursey/cmdk/commit/fb4ea04e9ec211777fbb39c6104e3c5f2ee107d2) fix/no-title-error branch
with-main with-fix-no-title-error

tnyo43 avatar May 17 '25 15:05 tnyo43

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

vercel[bot] avatar May 17 '25 15:05 vercel[bot]

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

elijaholmos avatar Jun 07 '25 03:06 elijaholmos

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!

tnyo43 avatar Jun 16 '25 04:06 tnyo43

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

wdelmas avatar Jul 03 '25 09:07 wdelmas

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

supuwoerc avatar Oct 09 '25 03:10 supuwoerc

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

supuwoerc avatar Oct 09 '25 03:10 supuwoerc