a11y: add aria-sort, SR announcements, Enter/Space operability to sor… - #1139
Open
Emelie-Dev wants to merge 1 commit into
Open
a11y: add aria-sort, SR announcements, Enter/Space operability to sor…#1139Emelie-Dev wants to merge 1 commit into
Emelie-Dev wants to merge 1 commit into
Conversation
…t control - Add visually-hidden rowgroup/columnheader surrogate carrying aria-sort per WAI-ARIA APG * primary -> ascending / descending, secondary -> other, inactive -> omitted (none default) - Add role=status aria-live=polite aria-atomic=true region gated by initialMountRef so page load does not spam 'Sorted by ...' announcement; announce only on user-driven sort changes - DropdownMenu content role=menu aria-label='Sort columns'; items role=menuitemcheckbox with aria-checked=true (primary) / mixed (secondary) / false (inactive) - Explicit Enter/Space handlers with preventDefault on each sort item and the secondary-sort chip close button, shared click handler preserves shiftKey semantics for secondary-sort activation - Secondary sort chip gains role=group with field+direction aria-label and per-field close-button aria-label - Decorative ChevronsUpDown and X icons marked aria-hidden, trigger aria-label embeds current state and Enter/Space open hint - Expand sort.test.tsx to 4 new suites covering aria-sort columnheader states, aria-live announcements (including no-spam initial mount and primary+secondary text), Enter/Space operability (with preventDefault assertions) and menuitemcheckbox ARIA state Closes Stellopay#731
Contributor
|
@Emelie-Dev is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
a11y: add aria-sort, SR announcements, Enter/Space operability to transactions sort control
Closes #731.
Problem
components/transactions/sort.tsxrenders the active sort state visually (chevron icons and order badges) but provides no equivalent for screen readers:aria-sortattribute on the column headers driving the orderSolution
Scoped changes to exactly
components/transactions/sort.tsxand its test file, following existing design tokens and the Radix-UI wrapper patterns already used in the app.aria-sort semantics
Emits a visually-hidden surrogate
role=rowgroup > row > columnheadertree that maps eachSortFieldto a semantic column header carrying the correctaria-sortvalue:ascending/descendingother(per WAI-ARIA APG pattern for non-primary ordered columns)none)The surrogate keeps the change scoped to this file (issue scope is exactly
sort.tsx) and does not couple totransactions-table.tsx, whose column labels differ fromSORT_LABELS.Live-region announcements
A
role=status/aria-live=polite/aria-atomic=trueregion (.sr-only) announces human-readable"Sorted by Date descending, then by Amount ascending."text only whensortConfigsactually changes — aninitialMountRefguard prevents the spurious page-load announcement that would otherwise fire on every first render.Enter / Space operability
DropdownMenuItemgains an explicitonKeyDownthat callspreventDefault()(important for Space, which would otherwise scroll the page) and forwards to the shared click handler, so Shift-key semantics for secondary-sort activation work identically for keyboard and pointer users.<button>gets the same Enter/SpacepreventDefault-aware handler for symmetry.Menu-item ARIA state
DropdownMenuContent→role="menu",aria-label="Sort columns"DropdownMenuItem→role="menuitemcheckbox"witharia-checkedset to:truefor the primary sort columnmixedfor a secondary sort columnfalsefor inactive columnsTrigger + chip polish
ChevronsUpDownandXicons arearia-hidden.aria-labelembeds current primary / secondary state and the hint:Press Enter or Space to open the sort menu.role="group"with a field+direction label; the close button gets a per-fieldaria-label="Clear secondary sort by <field>"rather than a generic "Close".Tests
components/transactions/sort.test.tsxextended from 9 original tests to 4 new suites:preventDefault, ArrowDown is a no-op; Enter/Space activate secondary-clear withpreventDefaulton Spacearia-checked=true/mixedwithrole=menuitemcheckboxacross all fieldsRadix DropdownMenu mock updated to forward
role,aria-checked,onKeyDown,data-testidand setstabIndex={0}so jsdom fires keyboard events on the menu items.Validation
bg-[#160f17],border-[#2D2D2D],focus-visible:ring-*,sr-only).ariaSortForField,buildSortAnnouncement) at module top; state handling uses refs + effect, no React 19 / Next 15 anti-patterns; change is strictly scoped to the two files named in the issue.How to review
aria-sortchanges and the new order is announced on each switch.closes #731