feat(table): improve a11y for sorting and filtering controls#9
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b846aba73a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc') | ||
| } | ||
| }} | ||
| aria-label={`Sort by ${String(column.title)} ${sorted && sortOrder === 'asc' ? 'descending' : 'ascending'}`} |
There was a problem hiding this comment.
Avoid stringifying ReactNode in sort button labels
column.title is typed as ReactNode, so for common non-text headers (e.g., <span>Name</span> or icon+text JSX) String(column.title) becomes "[object Object]". In those cases the new accessible name becomes "Sort by [object Object] ...", which makes the control effectively unlabeled for screen-reader users; the same pattern also affects the filter select label. This regression appears whenever consumers pass JSX titles, which the public API explicitly allows.
Useful? React with 👍 / 👎.
Motivation
Description
aria-sortto sortable<th>elements with valuesascending,descending, ornonebased on current state inpackages/ui/src/components/data/Table.tsx.aria-labelto the header sort<button>to describe the next sort action (for exampleSort by Name ascending).aria-labelto per-column filter<select>controls asFilter ${column.title}and rely on native element keyboard behavior for Tab/Enter/Space support.Testing
npm run lint:uiand it completed successfully.npm run typecheck:ui(tsc --noEmit) and it completed successfully.Codex Task