fix(a11y): add button semantics to clickable datagrid/datatable rows - #11341
Open
forurmah wants to merge 1 commit into
Open
fix(a11y): add button semantics to clickable datagrid/datatable rows#11341forurmah wants to merge 1 commit into
forurmah wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
…(#11108)
Problem
Fixes #11108
Clickable rows in
<Datagrid rowClick="...">and<DataTable rowClick="...">are rendered as plain
<tr>elements with only anonClickhandler. Screenreaders announce them as static text, not as interactive controls, even
though pressing Enter on them (when somehow focused) triggers navigation.
Reported by a blind NVDA user testing the react-admin helpdesk demo, who
expected clickable rows to be exposed as links or buttons.
Fix
When a row is clickable (
rowClickis set, or the resource has a show/editview), the row now:
role="button"tabIndex={0}so it's reachable via keyboardEnterandSpacevia a newonKeyDownhandler, calling thesame
handleClicklogic used for mouse clicksNon-clickable rows are unaffected — no
role,tabIndex, oronKeyDownare added.
Applied to both:
packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx(legacyDatagrid)packages/ra-ui-materialui/src/list/datatable/DataTableRow.tsx(DataTable)Testing
Added tests in
DatagridRow.spec.tsxcovering:role="button"andtabIndex="0"present on clickable rows, absent on non-clickable rowsEntertriggers the same navigation as a clickSpacetriggers the same navigation as a clickTab) do not trigger navigationAll existing
DatagridRowtests still pass unmodified.Manually verified row navigation still works via mouse click and that
existing row interactions (checkbox selection, expand toggle) are
unaffected, since their handlers already call
event.stopPropagation().