Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probably we should use status and alert role instead of alertdialog role for useToast and Toast component #7318

Open
mehm8128 opened this issue Nov 5, 2024 · 0 comments

Comments

@mehm8128
Copy link
Contributor

mehm8128 commented Nov 5, 2024

Provide your feedback here.

Hi, I found the issue about useToast (in React Aria) and Toast component (in React Spectrum).
I'm not so skilled about a11y, so if there is any mistake I'd like you to let me know.
Currently useToast returns alertdialog role as toastProps, but this is not ideal.
https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/toast/src/useToast.ts#L77

In ARIA: alertdialog role - Accessibility | MDN, there are such explanations.

The alertdialog role is used to notify users of urgent information that demands the user's immediate attention.

Because of its urgent nature, interrupting the user's workflow, alert dialogs must always be modal.

But it seems that useToast is intended to be used for more casual usage and Toast component is not modal, so I think we should not use alertdialog role for useToast.

And Taking a look at Accessible Rich Internet Applications (WAI-ARIA) 1.1 - alertdialog, there is the same explanation.

Content authors SHOULD make alert dialogs modal by ensuring that, while the alertdialog is shown, keyboard and mouse interactions only operate within the dialog. See aria-modal.

info:
In Chakra-UI, Toast has status role
https://github.com/chakra-ui/zag/blob/main/packages/machines/toast/src/toast.connect.ts#L59

and also in Vercel, Toast has status role (I was not able to source code).
https://vercel.com/geist/toast

So I think it is good to use status role and remove alertdialog role, and also we should be cautious to pass alert as contentProps (because it is also used for important, and time-sensitive information, MDN says).
ARIA: status role - Accessibility | MDN
ARIA: alert role - Accessibility | MDN

And I found another one issue that alertdialog element should have aria-describedby but at least the demo in our document useToeast – React Aria and Toast – React Spectrum, accessible description is not provided for alertdialog.

In MDN

The alert dialog text must have an accessible description using aria-describedby.

In WAI-ARIA

Authors SHOULD use aria-describedby on an alertdialog to reference the alert message element in the dialog.

Thank you for reading this feedback, I'm happy if you will consider about it.

🔦 Context

No response

💻 Code Sample

No response

Version

No response

What browsers are you seeing the problem on?

No response

If other, please specify

No response

What operating system are you using?

No response

@mehm8128 mehm8128 changed the title Should not use alertdialog role for useToast and Toast component Probably we should not use alertdialog role for useToast and Toast component Nov 5, 2024
@mehm8128 mehm8128 changed the title Probably we should not use alertdialog role for useToast and Toast component Probably we should use status and alert role instead of alertdialog role for useToast and Toast component Nov 8, 2024
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

No branches or pull requests

1 participant