fix(datatable): improve sortable header accessibility#4340
Conversation
✅ 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. 🔘 Update the status of your PRYour PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate. Where 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 #4340 +/- ##
=============================================
Coverage 94.40% 94.41%
=============================================
Files 242 242
Lines 4309 4316 +7
Branches 981 986 +5
=============================================
+ Hits 4068 4075 +7
Misses 237 237
Partials 4 4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
c87ad1a to
24e6fa4
Compare
Description
This PR improves DataTable sortable header accessibility without changing the public DataTable API.
It addresses 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
defaultPropswarnings. These warnings were observed during testing, but they existed before this PR and are not related to the a11y fixes here.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.getHeaderProps()may return a Reactkey; this PR now applies that key directly to<th>and spreads the remaining header props to avoid the React key-spread warning.Verification
npm test -- --runTestsByPath src/DataTable/tests/TableHeaderCell.test.jsx --coverage=falsepassed.npm test -- --runTestsByPath src/DataTable/tests/Table.test.jsx --coverage=falsepassed.npm test -- --runTestsByPath src/DataTable/tests/DataTable.test.jsx --coverage=falsepassed.npm test -- --runTestsByPath src/DataTable/tests/TableHeaderCell.test.jsx src/DataTable/tests/DataTable.test.jsx --coverage=falsepassed.npm run lintpassed.git diff --checkpassed./components/datatable/:scope="col"appeared on<th>; active sorted headers exposedaria-sort; unsorted headers omittedaria-sort; sortable headers renderedbutton type="button".Deploy Preview
https://deploy-preview-4340--paragon-openedx-v23.netlify.app/components/datatable/
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.