Skip to content

fix sorting replacement in single-sort mode - #6431

Merged
KevinVandy merged 2 commits into
betafrom
agent/fix-4309-single-sort
Jul 30, 2026
Merged

fix sorting replacement in single-sort mode#6431
KevinVandy merged 2 commits into
betafrom
agent/fix-4309-single-sort

Conversation

@KevinVandy

@KevinVandy KevinVandy commented Jul 17, 2026

Copy link
Copy Markdown
Member

What changed

  • distinguish actual multi-sort actions from single-sort actions
  • when an existing column is toggled without multi-sort, reduce the sorting state to that column
  • preserve the normal toggle/remove cycle while discarding the other multi-sort entries
  • add a regression test for toggling the last column of an existing multi-sort state

Why

toggleSorting(..., false) previously kept the other sorted columns when the target column was already the final entry. The action was classified as a toggle, and the toggle path mapped over the entire previous state.

Single-sort actions should leave at most the selected column in the sorting state, regardless of its prior position.

Validation

  • packages/table-core/tests/unit/features/row-sorting/rowSortingFeature.utils.test.ts — 47 tests passed
  • Prettier and git diff --check

Closes #4309

Summary by CodeRabbit

  • Bug Fixes

    • Improved single-column sorting behavior so toggling a column replaces other active sort criteria.
    • Removing sorting in single-sort mode now clears the sorting state.
    • Preserved independent column sorting behavior when multi-column sorting is enabled.
  • Tests

    • Added coverage for toggling a column while multiple sort criteria are active in single-sort mode.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

column_toggleSorting now separates multi-sort and normal-sort behavior. Multi-sort toggles or removes only the targeted column, while normal-sort toggles replace the sorting state and removals clear it. A unit test covers single-sort replacement.

Changes

Row sorting toggle behavior

Layer / File(s) Summary
Toggle sorting state and validation
packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts, packages/table-core/tests/unit/features/row-sorting/rowSortingFeature.utils.test.ts
column_toggleSorting derives multi-sort mode explicitly, preserves targeted updates in multi-mode, resets state in normal mode, and tests replacement of multiple entries with the toggled column.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: conao3

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code resets single-sort toggles to a single column and the new test covers the reported regression.
Out of Scope Changes check ✅ Passed The diff stays focused on row-sorting logic and its regression test, with no unrelated changes evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing single-sort mode to replace the sorting state instead of preserving other columns.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-4309-single-sort

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Jul 17, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 06353c5

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 7m 55s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 46s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-30 22:24:33 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown
More templates

@tanstack/alpine-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/alpine-table@6431

@tanstack/angular-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table@6431

@tanstack/angular-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table-devtools@6431

@tanstack/ember-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/ember-table@6431

@tanstack/lit-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/lit-table@6431

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6431

@tanstack/preact-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table@6431

@tanstack/preact-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table-devtools@6431

@tanstack/react-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table@6431

@tanstack/react-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table-devtools@6431

@tanstack/solid-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table@6431

@tanstack/solid-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table-devtools@6431

@tanstack/svelte-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/svelte-table@6431

@tanstack/table-core

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-core@6431

@tanstack/table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-devtools@6431

@tanstack/vue-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table@6431

@tanstack/vue-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table-devtools@6431

commit: 06353c5

@KevinVandy
KevinVandy marked this pull request as ready for review July 30, 2026 22:13
@KevinVandy
KevinVandy merged commit 147a6aa into beta Jul 30, 2026
9 checks passed
@KevinVandy
KevinVandy deleted the agent/fix-4309-single-sort branch July 30, 2026 23:57
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.

toggleSorting preserve the multi selection

1 participant