[6.x] Expose aria-sort on sortable listing column headers - #15403
Merged
Merged
Conversation
Listing headers are buttons that sort the table, but the sort state was never exposed to assistive technology. HeaderCell already computes isCurrentSortColumn and reads sortDirection, so this binds them to aria-sort on the th. Fixes statamic#15398 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013YZV7JD2cyMHSeSu2fUXCK
Member
|
Thank you! |
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.
Fixes #15398.
Listing column headers are buttons that sort the table, but
aria-sortwas never set on the<th>— before or after sorting. A screen reader user can trigger a sort and gets no confirmation of which column is active or in which direction.grep -rn "aria-sort" resources/jsreturned zero matches across the whole Control Panel.WCAG 2.1 SC 1.3.1 and SC 4.1.2 (both Level A). Affects every listing: entries, terms, assets, users, forms, submissions, roles, groups.
The change
HeaderCell.vuealready had everything needed — it computesisCurrentSortColumnand readssortDirectionfrom the listing context. This just binds them:Non-sortable columns get no attribute at all, which is correct —
aria-sorton a column that cannot be sorted would be misleading.Tests
Added
resources/js/tests/components/ListingHeaderCell.test.jswith three cases:aria-sort="none"ascending/descendingaria-sortConfirmed the tests fail against the unpatched component (2 of 3 fail; the third guards against regression) and pass with it.
Full unit suite: 566 passed, 9 failed. Those 9 are pre-existing
LivePreviewfailures on a clean6.xcheckout (localStorageis not available in the unit environment) — the same 9 fail without this branch. Net effect of this PR is +3 tests, no change to existing results.Notes
Found during a WCAG 2.1 AA audit of the CP. AI tools were used to draft this; the change, the tests, and the before/after verification were reviewed by hand.