Skip to content

DataTable: Add externalSorting prop to disable client-side sorting#7488

Merged
francinelucca merged 2 commits intomainfrom
koesie10/data-table-disable-client-side-sorting
Feb 2, 2026
Merged

DataTable: Add externalSorting prop to disable client-side sorting#7488
francinelucca merged 2 commits intomainfrom
koesie10/data-table-disable-client-side-sorting

Conversation

@koesie10
Copy link
Contributor

@koesie10 koesie10 commented Jan 30, 2026

This adds a new prop to the DataTable to disable client-side sorting when the DataTable to improve the UX when the table is showing paginated data that is loaded from the server.

Changelog

New

  • Adds a new externalSorting prop to DataTable

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2026

🦋 Changeset detected

Latest commit: f145a28

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jan 30, 2026
@github-actions
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@koesie10 koesie10 added integration-tests: skipped manually Changes in this PR do not require an integration test and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jan 30, 2026
@github-actions github-actions bot temporarily deployed to storybook-preview-7488 January 30, 2026 11:07 Inactive
Copy link
Member

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

one change request, other than that LGTM!
Also let's not skip the integration tests 🙏🏽

* table. Use this when sorting is handled server-side. The `onToggleSort`
* callback will still be fired when a sortable column header is clicked.
*/
externalSorting?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

let's add this new prop to the DataTable props file as well -> https://github.com/primer/react/blob/main/packages/react/src/DataTable/DataTable.docs.json

@francinelucca francinelucca removed the integration-tests: skipped manually Changes in this PR do not require an integration test label Jan 30, 2026
@koesie10 koesie10 marked this pull request as ready for review February 2, 2026 09:54
@koesie10 koesie10 requested a review from a team as a code owner February 2, 2026 09:54
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Feb 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

Copy link
Contributor

Copilot AI left a 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 PR adds a new externalSorting prop to the DataTable component to support server-side sorting scenarios. When enabled, the table maintains sort state UI (sort direction indicators and callbacks) without performing client-side data sorting, allowing consumers to handle sorting externally.

Changes:

  • Added externalSorting boolean prop to DataTable and useTable hook
  • Modified sortRows function to skip client-side sorting when externalSorting is true
  • Added comprehensive test coverage for the new functionality

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react/src/DataTable/DataTable.tsx Added externalSorting prop to DataTableProps and passed it through to useTable hook
packages/react/src/DataTable/useTable.ts Added externalSorting parameter to TableConfig and early return in sortRows function when enabled
packages/react/src/DataTable/tests/DataTable.test.tsx Added comprehensive test verifying that client-side sorting is disabled while sort state and callbacks still function correctly
packages/react/src/DataTable/DataTable.docs.json Added documentation for the new externalSorting prop
.changeset/calm-readers-send.md Added changeset entry marking this as a minor release

@primer-integration
Copy link

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/12364

@primer-integration
Copy link

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

Copy link
Member

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

:shipit:

@francinelucca francinelucca added this pull request to the merge queue Feb 2, 2026
Merged via the queue into main with commit fe85519 Feb 2, 2026
67 of 68 checks passed
@francinelucca francinelucca deleted the koesie10/data-table-disable-client-side-sorting branch February 2, 2026 17:09
@primer primer bot mentioned this pull request Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants