-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
MudAlert, MudToggleIconButton, MudChip: Improve accessibility #8966
Conversation
MudBlazor#8901 Alert: - Using aria-live="assertive" so screen readers immediately announce the alert's content to users - Add way of specifying the ARIA label for the close icon, with a default English one provided - Change from a Toggle to a regular button to show intent Buttons: - Add MudBaseButton.AriaLabel and hooked it up - Add ToggleIconButton.AriaLabel, ToggleIconButton.ToggledAriaLabel Chip: - Add role="button" to indicate the chip is interactive - Add CloseIconAriaLabel - Closes MudBlazor#6278 - Add role="group" to ChipSet
I'm no accessibility expert but I'm learning. My goal is to make a noticeable difference in the usability for people with disabilities |
This comment was marked as outdated.
This comment was marked as outdated.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #8966 +/- ##
==========================================
+ Coverage 89.82% 90.50% +0.67%
==========================================
Files 412 395 -17
Lines 11878 12128 +250
Branches 2364 2364
==========================================
+ Hits 10670 10976 +306
+ Misses 681 620 -61
- Partials 527 532 +5 ☔ View full report in Codecov by Sentry. |
@igotinfected FYI |
Rest LGTM |
Awesome! LGTM, the only thing I'm not sure about is the default I did so in MudBlazor/src/MudBlazor/Components/NavMenu/MudNavGroup.razor Lines 7 to 17 in 3fdc056
Also thank you for the accessibility issue @danielchalmers ❤️ Bit busy with work again but I'll try crossing some things off the list if/when I find the time :) |
True, those aria label parameters which we can expect to be the same for all instances of a component, such as "Close" can be removed and added to the localized resources instead. |
@henon Could you show me how it would be done for this PR? |
I think @igotinfected can explain it more expertly. A part of the solution is also seen above in his code snippet:
|
You can double click the For Visual Studio I don't remember but there should be something similar. I remember using a resx manager extension though to make it a little easier. You can then add your key, like this one for You can use The keys added there will be auto-generated in the And you use it like this in the @inject InternalMudLocalizer Localizer
@Localizer[nameof(LanguageResource.<key name>), <parameters if resource key has parameters>] The |
@igotinfected Nice, thanks a lot for that, PR has been updated! So you think the focus shouldn't be AriaLabel properties for elements with an existing purpose but the language resource file instead? And still have AriaLabels (if relevant) for core components like button, icon button, etc. |
@henon I bound the Like (psuedocode) <div @attributes="@ComponentAttributes">
</div>
@code {
public Dictionary<string, object?> UserAttributes { get; set; } = new Dictionary<string, object?>();
private Dictionary<string, object?> ComponentAttributes
{
get
{
var dict = new Dictionary<string, object?>();
if (IsClickable)
{
dict.Add("role", "button");
}
foreach (var attr in UserAttributes)
{
dict[attr.Key] = attr.Value;
}
return dict;
}
}
}
|
I think it will be a case by case, we can provide sensible defaults but still allow users to provide their own values when it makes sense to do so. Probably something that will come up in the future once localization really gets going. The goal should be for all components/html tags users don't have direct access to (say a filter button integrated into |
Also regarding Say there is <div @attributes="@UserAttributes" role="button"></div>
<!-- will output -->
<div role="button"></div>
<div role="button" @attributes="@UserAttributes"></div>
<!-- will output -->
<div role="notbutton"></div> |
@henon Ready for review. This is the simplest way of handling the attributes but I believe it does mean that if someone write |
If we want the user's attributes to take precedence then we need to put |
Because it's a binding it still takes over @henon |
Hmm I am not sure I get that but I think we worry about it when somebody really needs this. No need going down that rabbit hole right now. |
Thanks! |
Description
Part of a series in #8901
Alert:
mud-alert-close-button
classToggleIconButton:
Chip:
MudElement:
1
Originally I added AriaLabel properties to the button but that required extra workarounds for backwards compatibility and just seemed unnecessary. Not sure which criteria we used for the
Title
property but that isn't necessarily needed either 🤷How Has This Been Tested?
visually
Type of Changes
Checklist
dev
).