Skip to content

fix(data-grid): row selection selects correct row when filtering is applied#1113

Merged
sadmann7 merged 2 commits intomainfrom
sadman/fix-row-selection-filtered-data
Feb 24, 2026
Merged

fix(data-grid): row selection selects correct row when filtering is applied#1113
sadmann7 merged 2 commits intomainfrom
sadman/fix-row-selection-filtered-data

Conversation

@sadmann7
Copy link
Owner

Use row.id instead of row.index for onRowSelect to fix incorrect row selection when data is filtered. Row selection state is keyed by row.id, so using the id directly ensures the correct row is selected regardless of filtering/sorting.

Fixes #1107

Use row.id instead of row.index for onRowSelect to fix incorrect row
selection when data is filtered. Row selection state is keyed by row.id,
so using the id directly ensures the correct row is selected regardless
of filtering/sorting.

Fixes #1107

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

vercel bot commented Feb 24, 2026

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

Project Deployment Actions Updated (UTC)
tablecn Ready Ready Preview, Comment Feb 24, 2026 8:39am

Request Review

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 fixes a critical bug where selecting rows in a filtered data grid would select incorrect rows. The issue occurred because row selection was using row indices (which change with filtering/sorting) instead of stable row IDs.

Changes:

  • Changed onRowSelect signature from accepting rowIndex: number to rowId: string
  • Updated row selection state tracking to use lastClickedRowId instead of lastClickedRowIndex
  • Added comprehensive test coverage for row selection with filtering applied

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
src/types/data-grid.ts Updated onRowSelect type signature to accept rowId: string instead of rowIndex: number
src/hooks/use-data-grid.ts Modified state tracking to use row IDs, updated onRowSelect implementation to find rows by ID, and properly handle shift-selection with ID lookups
src/hooks/test/use-data-grid.test.tsx Added getRowId to existing tests and created new test validating correct row selection with filtering
src/components/data-grid/data-grid-select-column.tsx Updated component to pass row.id instead of row.index to onRowSelect
src/app/data-grid-render/components/data-grid-render-demo.tsx Updated demo component to pass row.id instead of row.index to onRowSelect

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

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.

[bug]: Data Grid Live Select does not select correct row when selecting on filtered data

2 participants