Add support for role="alertdialog"
to <Dialog>
component
#2709
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our
<Dialog>
component in React and Vue unconditionally sets the role todialog
. However, there are situations when a role ofalertdialog
would be more appropriate. This PR allows the user to choose between the two and will fallback todialog
if passed a role that is invalid or otherwise not suitable for use by the<Dialog>
component.The
alertdialog
role can be used when: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