PivotGrid A11y and KBN - The expand icons are not accessible via keyboard (KBN)#33709
PivotGrid A11y and KBN - The expand icons are not accessible via keyboard (KBN)#33709aleksei-semikozov wants to merge 20 commits into
Conversation
05552a8 to
50e613c
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves dxPivotGrid accessibility/keyboard navigation by making expand/collapse controls operable via keyboard and exposing expanded state via ARIA attributes.
Changes:
- Added keyboard handling so Enter/Space on expandable header cells toggles expansion.
- Added
aria-expandedandtabindex="0"to expandable header<td>elements. - Added QUnit coverage for keyboard toggling behavior and the new accessibility markup.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/pivotGrid.tests.js | Adds keyboard-driven expand/collapse tests (Enter/Space and negative cases). |
| packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/pivotGrid.markup.tests.js | Adds markup tests validating aria-expanded and tabindex for expandable vs non-expandable cells. |
| packages/devextreme/js/__internal/grids/pivot_grid/m_widget.ts | Adds keydown handling on cells to toggle expansion via keyboard. |
| packages/devextreme/js/__internal/grids/pivot_grid/area_item/m_area_item.ts | Adds aria-expanded and tabindex attributes to expandable header cells during rendering. |
There was a problem hiding this comment.
aria-expanded is valid on gridcell but not on cell (implicit role of <td> in a plain <table>). The pivot grid table has no role="grid". Was this tested with a screen reader?
There was a problem hiding this comment.
Isn't it risky to rely on the absence of aria-expanded to identify a non-expandable cell? If aria-expanded is ever removed or renamed, this selector silently targets the wrong element. Wouldn't selecting by row/column index be more reliable?
There was a problem hiding this comment.
I tested it locally and found out that _handleCellKeyDown delegates to _handleCellClick, which also triggers cell click handlers. Since a keyboard expand is not a click, shouldn't the expand/collapse logic be called directly instead?
There was a problem hiding this comment.
tabindex="0" makes the cell focusable, but outline: 0 is set on all tds in the PivotGrid styles, so there's no visible focus indicator. Keyboard users can't see which cell is focused. Shouldn't a focus style be added? At least I tested it locally and couldn't see a focus thing visually.
0de4c7e to
21d0530
Compare
| return; | ||
| } | ||
| e.preventDefault(); | ||
| this._trigger('onCellClick', args); |
There was a problem hiding this comment.
CellClickEvent types event in d.ts as MouseEvent | PointerEvent. I'm not sure but now it may need KeyboardEvent added since onCellClick now fires from keyboard too
| span.classList.add(PIVOTGRID_EXPAND_CLASS); | ||
| div.appendChild(span); | ||
| td.appendChild(div); | ||
| td.setAttribute('role', 'button'); |
There was a problem hiding this comment.
I agree with copilot. I am not sure if role=button is ok for table cells. I think we need to check screen readers output or discuss it with Andrey D.
No description provided.