Skip to content

Comments

fix(data-grid): preserve onRowSelectionChange tanstack feature#1110

Merged
sadmann7 merged 1 commit intomainfrom
sadman/preserve-row-selection-change
Feb 17, 2026
Merged

fix(data-grid): preserve onRowSelectionChange tanstack feature#1110
sadmann7 merged 1 commit intomainfrom
sadman/preserve-row-selection-change

Conversation

@sadmann7
Copy link
Owner

Allow hoisting up of row selection state by calling the prop callback after internal state updates, following the same pattern used for onSortingChange and onColumnFiltersChange.

Allow hoisting up of row selection state by calling the prop callback
after internal state updates, following the same pattern used for
onSortingChange and onColumnFiltersChange.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings February 17, 2026 07:42
@vercel
Copy link

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tablecn Ready Ready Preview Feb 17, 2026 7:42am

Request Review

@sadmann7 sadmann7 merged commit 1629645 into main Feb 17, 2026
11 checks passed
@sadmann7 sadmann7 deleted the sadman/preserve-row-selection-change branch February 17, 2026 07:43
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

Updates useDataGrid’s internal onRowSelectionChange wrapper to call the user-provided onRowSelectionChange callback after internal state updates, enabling selection changes to be observed/hoisted similarly to sorting and column filters.

Changes:

  • Invoke propsRef.current.onRowSelectionChange after batching internal row-selection related store updates.
  • Update useCallback dependencies accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

store.setState("editingCell", null);
});

propsRef.current.onRowSelectionChange?.(updater);
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

onRowSelectionChange here calls the user prop with updater, but the surrounding handlers (onSortingChange / onColumnFiltersChange) pass the resolved next state value. Since this function already computes newRowSelection, consider invoking propsRef.current.onRowSelectionChange with newRowSelection to match the established pattern and avoid parent state updates diverging if the parent applies a functional updater against a different previous selection state.

Copilot uses AI. Check for mistakes.
store.setState("editingCell", null);
});

propsRef.current.onRowSelectionChange?.(updater);
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

This change introduces a new external behavior (calling propsRef.current.onRowSelectionChange from the internal handler) but there isn't a corresponding test (unlike sorting/filtering callbacks). Add a unit test that triggers a row selection change and asserts the callback is called with the expected argument shape/value so regressions are caught.

Suggested change
propsRef.current.onRowSelectionChange?.(updater);
propsRef.current.onRowSelectionChange?.(newRowSelection);

Copilot uses AI. Check for mistakes.
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