MudDataGrid: Add default and customizable ARIA semantics to select column#12911
Conversation
There was a problem hiding this comment.
Pull request overview
Adds built-in and customizable ARIA semantics for SelectColumn-based row selection in MudDataGrid, improving accessible naming for selection checkboxes and exposing selection state via aria-selected only when checkbox selection controls are present.
Changes:
- Added localized default labels for row and select-all selection checkboxes, plus
AriaLabelFuncfor per-row customization. - Derived default row checkbox labels from visible value-bearing columns and disambiguated duplicates.
- Rendered
aria-selectedon data rows only when aSelectColumnis present and the row is selectable; expanded unit tests and updated docs.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/MudBlazor/Resources/LanguageResource.resx | Adds new localization keys for “Select row” / “Select all rows”. |
| src/MudBlazor/Components/DataGrid/SelectColumn.razor.cs | Adds AriaLabelFunc + localizer-backed label resolution helpers. |
| src/MudBlazor/Components/DataGrid/SelectColumn.razor | Wires default/custom ARIA labels into row and select-all checkboxes. |
| src/MudBlazor/Components/DataGrid/MudDataGrid.razor.cs | Adds row label derivation/disambiguation + selection-state helpers. |
| src/MudBlazor/Components/DataGrid/MudDataGrid.razor | Plumbs per-row label data into cell creation. |
| src/MudBlazor/Components/DataGrid/DataGridVirtualizeRow.razor | Adds aria-selected row attributes + computes/passes row checkbox labels. |
| src/MudBlazor/Components/DataGrid/CellContext.cs | Carries per-row checkbox label through CellContext. |
| src/MudBlazor/Components/DataGrid/Cell.cs | Creates CellContext with optional per-row checkbox label. |
| src/MudBlazor.UnitTests/Components/DataGridTests.cs | Adds coverage for default/custom labels, duplicates, and aria-selected behavior. |
| src/MudBlazor.Docs/Pages/Components/DataGrid/Examples/DataGridSelectionExample.razor | Updates example to demonstrate AriaLabelFunc. |
| src/MudBlazor.Docs/Pages/Components/DataGrid/DataGridPage.razor | Documents the new ARIA label behavior and customization hook. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I'll have to save this for the next release so I have more time to review it |
|
Simplifications suggested by GPT-5.4:
|
I simplified the DataGrid selection ARIA implementation to the leaner model you asked for. SelectColumn now uses only two default labels, "Select row" and "Select all rows", with AriaLabelFunc still available to override per-row labels. The row-content inference pipeline was removed from SelectColumn.razor.cs, MudDataGrid.razor.cs, MudDataGrid.razor, DataGridVirtualizeRow.razor, Cell.cs, and CellContext.cs. aria-selected behavior stayed scoped to SelectColumn selection semantics, and disabled rows still omit it. I also collapsed the tests in DataGridTests.cs to match the simpler behavior and updated the docs wording in DataGridPage.razor so it no longer claims labels are derived from row content.
|
🤖💬 e48c593 keeps the key accessibility improvements but removes the parts that were doing too much guessing. What stays:
What changed:
Why this is better:
|
versile2
left a comment
There was a problem hiding this comment.
Verdict:
The ARIA implementation is valid and accessible.
For optimal user experience, row-specific labels are preferred, but "Select row" is an acceptable fallback and meets minimum accessibility requirements.
Final Verdict & Feedback:
The PR is focused, well-documented, and thoroughly tested.
Accessibility is improved and customizable.
No critical issues found; all review checklist items are satisfied.****
Overview
This PR improves accessibility for row selection in
MudDataGridby:AriaLabelFuncparameter onSelectColumn.aria-selectedonly for rows that participate inSelectColumn-based selection, and omitting it for disabled rows.Key Changes
SelectColumnacceptsAriaLabelFuncfor custom per-row accessible names.AriaLabelFuncreturns null/empty, the default label is used.aria-selectedis rendered only for selectable rows when aSelectColumnis present.AriaLabelFunc.aria-selectedbehavior.Motivation
Previously, DataGrid selection checkboxes lacked accessible names and did not expose selection state, making them difficult to use with assistive technology. This PR ensures all selection controls are accessible by default and easily customizable.
Example Usage
Checklist
aria-selectedonly for selectable rowsThis PR brings MudDataGrid selection controls up to modern accessibility standards while remaining easy to use and extend.