fix(datatable): improve sortable header accessibility#4345
Conversation
Co-authored-by: Codex <codex@openai.com>
✅ Deploy Preview for paragon-openedx-v23 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thanks for the pull request, @edschema! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-23.x #4345 +/- ##
=============================================
Coverage 94.40% 94.41%
=============================================
Files 242 242
Lines 4309 4316 +7
Branches 981 1018 +37
=============================================
+ Hits 4068 4075 +7
+ Misses 237 233 -4
- Partials 4 8 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
This PR improves DataTable sortable header accessibility, addressing three header behavior gaps:
aria-sort="ascending"oraria-sort="descending"; inactive/unsorted headers omitaria-sort.<th>, so sortable headers were not reachable by Tab. Sortable headers now render a native button inside the existing<th>, with React Table sort toggle props on the button for native Tab, Enter, and Space behavior.TableHeaderCellnow rendersscope="col".Supporting changes:
In Scope
aria-sorton the sorted header cell.scope="col".Out of Scope / Future Work
keyspread anddefaultPropswarnings. This PR preserves the current React Table pattern where helper functions return bundled header/cell props, including key, to keep the accessibility fix tightly scoped. Cleaning up Reactkeyprops and related warnings should happen in a separate maintenance PR.Reviewer Notes / Decisions
aria-sortis intentionally set only on the active sorted header cell. Inactive sortable headers omitaria-sort, following W3C/APG guidance that the attribute is set on the currently sorted column and moved when sorting changes.<th>. This follows the APG sortable-table pattern and keeps keyboard behavior native.scope="col"is applied to allTableHeaderCell<th>elements because this component owns DataTable column-header markup.keyvalues, and DataTable currently follows an older pattern of spreading those prop objects into JSX. This PR keeps that existing pattern unchanged so the review stays focused on sortable-header accessibility. Key-prop cleanup should be handled separately across the relevant DataTable header/row/cell paths.Verification
npm test -- --runTestsByPath src/DataTable/tests/TableHeaderCell.test.jsx --coverage=falsepassed.npm test -- --runTestsByPath src/DataTable/tests/DataTable.test.jsx --coverage=falsepassed.npm test -- --runTestsByPath src/DataTable/tests/Table.test.jsx --coverage=falsepassed.npm run lintpassed.git diff --checkpassed.Deploy Preview
https://deploy-preview-4345--paragon-openedx-v23.netlify.app/components/datatable/#frontend-filtering-and-sorting
Merge Checklist
pgn__DataTable classes under the existing.pgn__data-tablestyles; the new CSS does not reference primitive tokens and uses inheritance for button font, color, and text alignment.exampleapp?TableHeaderCelltests were added/updated and targeted DataTable tests passed.Post-merge Checklist
AI Disclosure
Codex was used to help diagnose the issue, catalog the current behavior, suggest an implementation shape, execute the fix, and generate the framework for the PR text based on Open edX guidances in the docs. Each step required manual review. Claude and Codex were both used to iterate on the plan and to perform a series of PR reviews.