Skip to content

feat(table): improve a11y for sorting and filtering controls#9

Merged
leno23 merged 2 commits into
mainfrom
codex/add-a11y-features-to-table-headers
May 10, 2026
Merged

feat(table): improve a11y for sorting and filtering controls#9
leno23 merged 2 commits into
mainfrom
codex/add-a11y-features-to-table-headers

Conversation

@leno23
Copy link
Copy Markdown
Owner

@leno23 leno23 commented May 9, 2026

Motivation

  • Improve screen reader and keyboard accessibility for table headers that support sorting and per-column filters.
  • Ensure sort state is exposed programmatically and controls provide clear, contextual labels for assistive technologies.

Description

  • Add aria-sort to sortable <th> elements with values ascending, descending, or none based on current state in packages/ui/src/components/data/Table.tsx.
  • Add a dynamic aria-label to the header sort <button> to describe the next sort action (for example Sort by Name ascending).
  • Add a readable aria-label to per-column filter <select> controls as Filter ${column.title} and rely on native element keyboard behavior for Tab/Enter/Space support.

Testing

  • Ran npm run lint:ui and it completed successfully.
  • Ran npm run typecheck:ui (tsc --noEmit) and it completed successfully.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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'}`}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@leno23 leno23 merged commit 081de83 into main May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant