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

Add support for role="alertdialog" to <Dialog> component #2709

Merged
merged 5 commits into from
Aug 28, 2023

Conversation

thecrypticace
Copy link
Contributor

Our <Dialog> component in React and Vue unconditionally sets the role to dialog. However, there are situations when a role of alertdialog would be more appropriate. This PR allows the user to choose between the two and will fallback to dialog if passed a role that is invalid or otherwise not suitable for use by the <Dialog> component.

The alertdialog role can be used when:

  • The message or action being presented is important enough that it needs to interrupt the user's workflow; AND
  • The dialog requires user interaction, confirmation, acknowledgement, etc…

For example, a confirmation dialog when deleting a user would be a suitable use case for role="alertdialog".

Take a look at the MDN docs for more details about the role and when it should be used.

Please note that a properly accessible alert dialog also requires the use of our Dialog Title and Dialog Description components — we do not currently warn if they are missing but may decide to do so in the future.

Fixes #2701

@vercel
Copy link

vercel bot commented Aug 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview Aug 28, 2023 5:32pm
headlessui-vue ✅ Ready (Inspect) Visit Preview Aug 28, 2023 5:32pm

@thecrypticace thecrypticace merged commit a6a2382 into main Aug 28, 2023
@thecrypticace thecrypticace deleted the alertdialog-support branch August 28, 2023 17:37
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

Successfully merging this pull request may close these issues.

Modal role="alertdialog"
2 participants