Skip to content

Accessibility: Fix `<Alert />` `role` usage

Warren Gifford requested to merge tr/global-alert-role into main

Created by: umpox

closes https://github.com/sourcegraph/sourcegraph/issues/35259

Description

Our Alert components have the role set to "alert" by default. This can cause some issues with certain alerts, for example: image

This isn't urgent for the user to be notified. In these cases we should not set the alert role.

MDN guidance on role="alert: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role

Warning: Because of its intrusive nature, the alert role must be used sparingly and only in situations where the user's immediate attention is required.

I think only setting in when the variant is danger | warning is a good middle ground. We might still have some areas where we need to override it, but for most cases this should be the desired behavior.

Test plan

Tested locally with a screen reader

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading