Skip to content

fix(datatable): improve sortable header accessibility - #4345

Open
edschema wants to merge 2 commits into
openedx:release-23.xfrom
Schema-Education:edschema/datatable-sort-header-a11y-clean
Open

fix(datatable): improve sortable header accessibility#4345
edschema wants to merge 2 commits into
openedx:release-23.xfrom
Schema-Education:edschema/datatable-sort-header-a11y-clean

Conversation

@edschema

@edschema edschema commented Jun 22, 2026

Copy link
Copy Markdown

Description

This PR improves DataTable sortable header accessibility.

Keyboard operation; Sortable headers now render a native button inside the existing <th>, with React Table sort toggle props on the button. This makes sortable headers reachable with Tab and operable with Enter and Space.

Sort state: Sorted headers now expose sort direction with aria-sort on the primary sorted header only. Inactive sortable headers and secondary multi-sort headers omit aria-sort.

Column scope declaration: DataTable header cells also render scope="col", and scoped DataTable styles keep the sort button aligned with the existing header layout and click target.

Out of Scope

  • Table captions, table labels, and explanatory text for sortable columns.
  • The test output includes a pre-existing React warning about spreading a key prop. DataTable uses helpers that return key with other props; React wants key passed as its own JSX attribute. This PR does not change the existing pattern because fixing would increase the scope to touch header, row, and cell code throughout DataTable. I think cleaning up the key warning belongs in a separate PR; this PR is scoped to just the a11y fixes.
  • The tests also show pre-existing React defaultProps warnings. These are not introduced by this PR and are out of scope.

Change Log

  • Render sortable DataTable headers as native buttons.
  • Move React Table sort toggle props from the <th> to the sort button.
  • Add aria-sort for the primary sorted column and omit it for inactive or secondary sorted columns.
  • Add scope="col" to DataTable header cells.
  • Add DataTable styles for sortable header button layout and click area.
  • Add tests for sort state, column scope, sortable button behavior, keyboard operation, DataTable sorting, and multi-sort aria-sort behavior.

Notes

  • Visual sort indicators still render for sorted columns, including secondary multi-sort columns. Only the primary sorted column exposes aria-sort.
  • The React key spread warning is existing behavior from React Table prop getters and is unchanged by this PR.
  • Accessibility review is recommended because this changes table header semantics and keyboard behavior.

Tests Done

  • npm test -- --runTestsByPath src/DataTable/tests/DataTable.test.jsx src/DataTable/tests/TableHeaderCell.test.jsx --coverage=false
  • git diff --check

Deploy Preview

https://deploy-preview-4345--paragon-openedx-v23.netlify.app/components/datatable/#frontend-filtering-and-sorting

Merge Checklist

  • If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Netlify deploy preview, if applicable.
    • No intended visual change; Netlify deploy preview review is pending.
  • Does your change adhere to the documented style conventions?
    • Added scoped pgn__ DataTable classes under the existing .pgn__data-table styles.
  • Do any prop types have missing descriptions in the Props API tables in the documentation site (check deploy preview)?
    • No documented public props were added.
  • Were your changes tested using all available themes (see theme switcher in the header of the deploy preview, under the "Settings" icon)?
    • Not run.
  • Were your changes tested in the example app?
    • Not run.
  • Is there adequate test coverage for your changes?
    • Focused TableHeaderCell tests and DataTable regression tests cover the changed behavior.
  • Consider whether this change needs to reviewed/QA'ed for accessibility (a11y). If so, please request an a11y review for the PR in the #wg-paragon Open edX Slack channel.
    • Accessibility review is recommended because this changes table header semantics and keyboard behavior.

Post-merge Checklist

  • Verify your changes were released to NPM at the expected version.
  • If useful, share the contribution in #show-and-tell.

AI Assistance

AI tools were used to aid in diagnosis, planning, implementation, and review. All work was checked and reviewed.

Co-authored-by: Codex <codex@openai.com>
@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy Preview for paragon-openedx-v23 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f9ad9ac
🔍 Latest deploy log https://app.netlify.com/projects/paragon-openedx-v23/deploys/6a6d2484e3dabf0007820eea
😎 Deploy Preview https://deploy-preview-4345--paragon-openedx-v23.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 22, 2026
@openedx-webhooks

openedx-webhooks commented Jun 22, 2026

Copy link
Copy Markdown

Thanks for the pull request, @edschema!

This repository is currently maintained by @openedx/committers-paragon.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jun 22, 2026
@edschema
edschema marked this pull request as ready for review June 22, 2026 14:16
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.26%. Comparing base (9340b9c) to head (f9ad9ac).
⚠️ Report is 13 commits behind head on release-23.x.

Additional details and impacted files
@@               Coverage Diff                @@
##           release-23.x    #4345      +/-   ##
================================================
- Coverage         94.40%   94.26%   -0.14%     
================================================
  Files               242      242              
  Lines              4309     4309              
  Branches            981     1038      +57     
================================================
- Hits               4068     4062       -6     
- Misses              237      238       +1     
- Partials              4        9       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jun 23, 2026
@mphilbrick211
mphilbrick211 requested a review from a team June 23, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

3 participants