ui: [bug]: Sheet error for screen reader users
Describe the bug
When using the Sheet component I get two errors:
DialogContent requires a DialogTitle for the component to be accessible for screen reader users.
If you want to hide the DialogTitle, you can wrap it with our VisuallyHidden component.
Warning: Missing Description or aria-describedby={undefined} for {DialogContent}.
Affected component/components
Sheet
How to reproduce
Using the https://ui.shadcn.com/blocks#dashboard-05 sample. Reduce width so that the Sheet shows; warnings in the console.
Codesandbox/StackBlitz link
No response
Logs
`DialogContent` requires a `DialogTitle` for the component to be accessible for screen reader users.
If you want to hide the `DialogTitle`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/dialog
---
Warning: Missing `Description` or `aria-describedby={undefined}` for {DialogContent}.
at DescriptionWarning (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-dialog/dist/index.mjs:457:11)
System Info
All browsers.
Before submitting
- I’ve made research efforts and searched the documentation
- I’ve searched for existing issues
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 14
- Comments: 17
Commits related to this issue
- fix(bug): add Drawer Title is a must - Title is a must!! - Source -> https://github.com/shadcn-ui/ui/issues/4302 — committed to alfieqashwa/billiard-app by alfieqashwa 2 years ago
- hotfix sheet error for screen reader users https://github.com/shadcn-ui/ui/issues/4302 — committed to vatoer/spmb-0 by vatoer 2 years ago
Also works only adding
sr-onlyclass toSheetHeader.This issue again becomes relevant with the recently released sidebar templates (on mobile). Slightly modified fix from @Maqed still works fine though.
Install
@radix-ui/react-visually-hidden& Add this in yoursidebar.tsx:Proposed fix in Sheet component:
First thing first you should install visually hidden component from RadixUI as Shadcn is built on top of it.
npm install @radix-ui/react-visually-hiddenThen use it as following:
I hope that helps!
It’s work
This is happening with the new Sidebar component because of the SheetContent too.
same thing happened when I used
CommandDialogthe
sr-onlysolution worked for me, but i also had to add<DialogDescription />to avoid the warningWarning: Missing Description or aria-describedby={undefined} for {DialogContent}.For the command, I found a temporary solution for my project:
Passing an empty
DialogTitleworked for me and stopped the error, so I’ll use it until an official fix is released.If you are using the Sidebar, open Sidebar definition and add
<SheetTitle></SheetTitle>in this block of code
This will fix the issue and you don’t need to provide a title unless you want to. If that’s what you are looking for.
@AsazuTaiga that works perfectly