Skip to content

Improve accessibility labels and localize picker buttons#11456

Merged
danielchalmers merged 7 commits intoMudBlazor:devfrom
danielchalmers:misc-a11y
Jun 6, 2025
Merged

Improve accessibility labels and localize picker buttons#11456
danielchalmers merged 7 commits intoMudBlazor:devfrom
danielchalmers:misc-a11y

Conversation

@danielchalmers
Copy link
Member

@danielchalmers danielchalmers commented Jun 6, 2025

Description

How Has This Been Tested?

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@danielchalmers danielchalmers requested a review from Copilot June 6, 2025 00:25
@danielchalmers danielchalmers added accessibility Accessibility concerns (ARIA, keyboard, focus, screen readers, contrast) localization Translations, locale formats, RTL layout, calendars labels Jun 6, 2025
@github-actions github-actions bot added the enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library label Jun 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refines accessibility and localization by converting ARIA/action labels to sentence case, adding dynamic show/hide swatch labels, and localizing picker adornment buttons.

  • Standardizes resource strings to sentence case and trims lengthy ARIA labels
  • Adds localized, state-dependent labels for color swatch toggling and tree-view expansion
  • Replaces hard-coded picker aria labels with localized defaults

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/MudBlazor/Resources/LanguageResource.resx Updated many resource values to sentence case; added new keys for show/hide swatches and open/expand actions
src/MudBlazor/Components/TreeView/MudTreeViewItemToggleButton.razor Injected localizer and added dynamic aria-label based on expand/collapse state
src/MudBlazor/Components/TimePicker/MudTimePicker.razor.cs Removed static AdornmentAriaLabel and set localized fallback in OnInitialized
src/MudBlazor/Components/DatePicker/MudDateRangePicker.razor.cs Removed static AdornmentAriaLabel but no localized fallback added
src/MudBlazor/Components/DatePicker/MudBaseDatePicker.razor.cs Added localized default for AdornmentAriaLabel in OnInitialized
src/MudBlazor/Components/ColorPicker/MudColorPicker.razor.cs Localized AdornmentAriaLabel on init
src/MudBlazor/Components/ColorPicker/MudColorPicker.razor Switched to dynamic, localized show/hide swatches aria-label
Comments suppressed due to low confidence (4)

src/MudBlazor/Components/DatePicker/MudDateRangePicker.razor.cs:31

  • The static AdornmentAriaLabel was removed but no localized fallback was added, leaving the button without an aria-label. Consider adding AdornmentAriaLabel ??= Localizer[LanguageResource.MudDateRangePicker_Open]; in OnInitialized to maintain accessibility.
AdornmentAriaLabel = "Open Date Range Picker";

src/MudBlazor/Components/TreeView/MudTreeViewItemToggleButton.razor:15

  • Remove the redundant '@' before Localizer inside the razor expression. It should be @(Expanded ? Localizer[LanguageResource.MudTreeView_CollapseItem] : Localizer[LanguageResource.MudTreeView_ExpandItem]) for valid syntax.
aria-label="@(Expanded ? @Localizer[LanguageResource.MudTreeView_CollapseItem] : @Localizer[LanguageResource.MudTreeView_ExpandItem])" />

src/MudBlazor/Components/TimePicker/MudTimePicker.razor.cs:550

  • Localizer is referenced here but not injected or defined in this code-behind. Add an [Inject] InternalMudLocalizer Localizer { get; set; } property (or similar) so that this reference compiles and runs correctly.
AdornmentAriaLabel ??= Localizer[LanguageResource.MudTimePicker_Open];

src/MudBlazor/Resources/LanguageResource.resx:262

  • [nitpick] Replacing specific close labels like "Close Alert" or "Close Picker" with a generic "Close" reduces context for screen-reader users. Consider retaining element context (e.g., "Close alert") for clarity.
<value>Close</value>

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 6, 2025

@codecov
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.13%. Comparing base (5509f51) to head (8b200e0).
Report is 7 commits behind head on dev.

Files with missing lines Patch % Lines
...ponents/TreeView/MudTreeViewItemToggleButton.razor 0.00% 0 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (75.00%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #11456   +/-   ##
=======================================
  Coverage   91.13%   91.13%           
=======================================
  Files         465      466    +1     
  Lines       14412    14417    +5     
  Branches     2790     2795    +5     
=======================================
+ Hits        13134    13139    +5     
  Misses        641      641           
  Partials      637      637           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danielchalmers danielchalmers changed the title Misc improvements to accessibility and localization Improve accessibility labels and localize picker buttons Jun 6, 2025
Copy link
Contributor

@meenzen meenzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localization looks correct, I will pull the LanguageResources changes into MudBlazor.Translations once this is merged.

Copy link
Member

@igotinfected igotinfected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Accessibility concerns (ARIA, keyboard, focus, screen readers, contrast) enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library localization Translations, locale formats, RTL layout, calendars

Projects

None yet

5 participants