-
Notifications
You must be signed in to change notification settings - Fork 616
DataTable: Add "SR only" text for sortable columns #6109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…can sort a column
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
size-limit report 📦
|
🦋 Changeset detectedLatest commit: 4d81bbd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This patch adds visually hidden text to sortable DataTable column headers (when unsorted) to improve screen-reader context and updates tests to match the new accessible names.
- Injects
<VisuallyHidden>sort ascending</VisuallyHidden>
for unsorted columns - Updates
DataTable.test.tsx
to look for the new accessible name - Adds a changeset entry for a patch release
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
packages/react/src/DataTable/Table.tsx | Wraps the ascending icon in a fragment and adds hidden text for unsorted state |
packages/react/src/DataTable/tests/DataTable.test.tsx | Adjusts getSortHeader calls to include the hidden text in the accessible name |
.changeset/dry-breads-attack.md | Adds a patch-level changeset noting the accessibility update |
Comments suppressed due to low confidence (2)
packages/react/src/DataTable/Table.tsx:162
- Ensure that
VisuallyHidden
is imported at the top of this file; without the import, the component reference will break the build.
{direction === SortDirection.NONE ? <VisuallyHidden>sort ascending</VisuallyHidden> : null}
.changeset/dry-breads-attack.md:5
- [nitpick] Consider adding or updating a Storybook story or a snippet in the docs to demonstrate the new screen-reader-only text in action for accessibility previews.
DataTable: Add visually hidden text to sortable DataTable column buttons
@@ -826,7 +826,7 @@ describe('DataTable', () => { | |||
|
|||
// When interacting with Column B, sort order should reset to ASC | |||
await user.click(screen.getByText('Column B')) | |||
expect(getSortHeader('Column A')).not.toHaveAttribute('aria-sort') | |||
expect(getSortHeader('Column A sort ascending')).not.toHaveAttribute('aria-sort') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This assertion now ties the test to the exact hidden text string, which could be brittle; consider using a regex or querying by part of the name (e.g., /Column A.*ascending/
) to make the test less coupled to implementation details.
expect(getSortHeader('Column A sort ascending')).not.toHaveAttribute('aria-sort') | |
expect(getSortHeader(/Column A.*ascending/)).not.toHaveAttribute('aria-sort') |
Copilot uses AI. Check for mistakes.
Add visually hidden text to sortable DataTable column buttons when not sorted.
Changelog
Changed
Rollout strategy
Testing & Reviewing
Merge checklist