fix(data-grid): preserve onRowSelectionChange tanstack feature#1110
fix(data-grid): preserve onRowSelectionChange tanstack feature#1110
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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.onRowSelectionChangeafter batching internal row-selection related store updates. - Update
useCallbackdependencies accordingly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| store.setState("editingCell", null); | ||
| }); | ||
|
|
||
| propsRef.current.onRowSelectionChange?.(updater); |
There was a problem hiding this comment.
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.
| store.setState("editingCell", null); | ||
| }); | ||
|
|
||
| propsRef.current.onRowSelectionChange?.(updater); |
There was a problem hiding this comment.
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.
| propsRef.current.onRowSelectionChange?.(updater); | |
| propsRef.current.onRowSelectionChange?.(newRowSelection); |
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.