Skip to content

feat: Add TableSortButton for atomic table components - #5269

Draft
gethinwebster wants to merge 1 commit into
mainfrom
dev-v3-gethinw-table-sort-button
Draft

gethinwebster wants to merge 1 commit into
mainfrom
dev-v3-gethinw-table-sort-button

Conversation

@gethinwebster

Copy link
Copy Markdown
Member

Description

Add TableSortButton, a sort control for a TableHeaderCell in the table atomic components. Consumers no longer have to build their own sort button.

  • Props: sortingState (sortable, ascending or descending), disabled, ariaLabel, onSortingChange with the next state, and the label as children.
  • It looks like the existing Table's sort control: the label truncates with an ellipsis, the caret never shrinks, sorted and hovered columns use the active colour, and it has the Cloudscape focus ring.
  • TableHeaderCell sets its own aria-sort from the button's state. An explicit ariaSort on the cell still wins.
  • The existing Table and TableSortButton now share one internal sort icon, so IconProvider's table.sortingIndicator customises both. The Table's DOM is unchanged.
  • New test utils: findLabel(), findSortingIcon(), getSortingState() and isDisabled().
  • The table-root/sorting dev page now uses it, with an unsortable column and its state in URL parameters.

API proposal: TfIwIU4ePrLh

Related links, issue #, if available: n/a

How has this been tested?

  • New unit tests: the label renders in a native button; each sort state shows its indicator and sets aria-sort on the header cell, including after the state changes; an explicit ariaSort wins; activating requests the next state; disabled blocks activation and shows the indicator only when sorted; ariaLabel; a custom indicator from IconProvider gets each state; and a11y validation.
  • Existing Table, table-root, table-header-cell and icon-provider unit tests pass. The documenter and test-utils snapshots only add the new component.
  • Manually, on the table-root/sorting dev page, in visual refresh: the sortable, sorted, hover and keyboard focus states.
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (d25043b) to head (1acbbf8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5269   +/-   ##
=======================================
  Coverage   97.83%   97.84%           
=======================================
  Files        1008     1013    +5     
  Lines       32590    32631   +41     
  Branches    12098    12110   +12     
=======================================
+ Hits        31886    31927   +41     
+ Misses        698      663   -35     
- Partials        6       41   +35     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch was successfully deployed

3 active deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant