-
Notifications
You must be signed in to change notification settings - Fork 608
feat: Add support for onToggleSort to DataTable #5991
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 42642de 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 |
👋 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! |
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
Adds a callback to notify consumers when a sortable column header is clicked.
- Introduces an optional
onToggleSort
prop inDataTableProps
. - Invokes
onToggleSort
with the column ID and new direction on header clicks. - Covers the new behavior with a unit test and a Storybook story.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
packages/react/src/DataTable/DataTable.tsx | Added onToggleSort prop and callback invocation in header logic |
packages/react/src/DataTable/tests/DataTable.test.tsx | New test verifying onToggleSort calls with correct parameters |
packages/react/src/DataTable/DataTable.features.stories.tsx | Added WithSortEvents Storybook example using onToggleSort |
.changeset/salty-bikes-learn.md | Changelog entry for the onToggleSort addition |
Comments suppressed due to low confidence (2)
packages/react/src/DataTable/tests/DataTable.test.tsx:891
- [nitpick] The variable name
handler
is generic; consider renaming it toonToggleSortMock
oronToggleSortHandler
to clarify its purpose.
const handler = jest.fn()
packages/react/src/DataTable/tests/DataTable.test.tsx:921
- Consider adding an assertion to verify that clicking the same column header a second time toggles back to
ASC
, e.g., a third click on 'First' callsonToggleSort('first', 'ASC')
.
expect(handler).toHaveBeenCalledTimes(2)
size-limit report 📦
|
👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/375773 |
🟢 golden-jobs completed with status |
Int tests were failing due to a date-related Flake, not this change. (Although the failing test used DataTable, which sparked extra investigation! 😅 ) |
Add support for
onToggleSort
prop toDataTable
.Changelog
New
onToggleSort
prop toDataTable
.Changed
Removed
Rollout strategy
Testing & Reviewing
Merge checklist