fix: set dialog title and description when provided to avoid Radix-ui error
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 |
|---|---|
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 |
can we get this merged? I'm running into this error as well.
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!
Feels like the project is not maintained anymore. Do you guys know a substitute library ?
I also encountered this error, and hope to accept this PR quickly~
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