material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[Snackbar] Screen reader not reading a snackbar when triggered from a button within a dialog

Open TheWilks opened this issue 4 years ago • 8 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Current behavior 😯

When snackbars are triggered from a button within a dialog they are not read by the screen reader.

Expected behavior 🤔

When snackbars are triggered from a button within a dialog they should be read by the screen reader.

Steps to reproduce 🕹

Steps

  1. User launches NVDA or JAWS
  2. User opens https://codesandbox.io/s/dialog-snackbar-not-accessible-gzl5o?file=/demo.js in Chrome, Firefox or Edge
  3. User clicks the "OPEN DIALOG" button and the dialog is launched
  4. User clicks the "OPEN SNACKBAR" button within the dialog and the snackbar is launch
  5. The screen reader does not read the snackbar and the user of the assistive technology is unaware the snackbar exists

Context 🔦

We are building forms and flows that combine the dialog and snackbar components. We need some none intrusive alerts that inform users their task was successful. Snackbars fit our need but are not accessible when triggered from a button within a dialog.

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

TheWilks avatar Dec 07 '21 15:12 TheWilks

This is related to #29080 and has been created so it can be handled as a separate issue.

TheWilks avatar Dec 07 '21 15:12 TheWilks

Is there any plan to resolve this issue?

vromaniv-liaison avatar May 23 '22 16:05 vromaniv-liaison

I suspected that the problem was the following:

  • This is a modal dialog, which means that when it's open, the rest of the page is aria-hidden.
  • When the snackbar first appears, it does so in the part of the page that is aria-hidden, which means that screen readers are unaware of it and cannot announce it.

I tested my theory by delaying the opening of the relevant snackbar:

  const handleClickOpenSnackbar3 = () => {
    setTimeout(() => {
      setOpenSnackbar3(true);
    }, 1000);
  };

And it worked (on Chrome + VoiceOver + macOS)! The snackbar is now announced. So you could use that as a workaround for now (there are bigger issues with the Modal component that Dialog is based on, which I think should be tackled in a larger refactor, as I've recommended in some other open issues).

xurxe avatar Dec 21 '22 14:12 xurxe

Referencing this: https://mui.com/base-ui/react-snackbar/

Just adding to this bug, I would also expect a screen reader to have the notification announced (and perhaps even pull focus)

Additionally notification div has role="presentation" which is incorrect, this basically removes semantics from the element but as it's a div anyway it's not needed.

This seems like a fail of WCAG 4.1.3 with my current understanding.

chris-gds avatar Sep 21 '23 13:09 chris-gds

Hi @chris-gds, Any update on this issue?

msftedad avatar Jan 22 '24 10:01 msftedad

Hi @chris-gds, Any update on this issue?

msftedad avatar Feb 08 '24 09:02 msftedad

For Mui4 users - another workaround is to pass disablePortal to <Dialog> but you might experience issues with stacking context.

pietmichal avatar Feb 18 '25 16:02 pietmichal

Hi Team, Any update on this issue?

msftedad avatar Nov 06 '25 06:11 msftedad