From d7e0a83c22bf2c05a93c0870f7dcb8e62831838d Mon Sep 17 00:00:00 2001 From: stdavis Date: Mon, 18 Nov 2024 14:47:00 -0700 Subject: [PATCH] chore: fix row selection when sorted --- src/components/Table.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Table.tsx b/src/components/Table.tsx index 8edae73..4198037 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -120,7 +120,7 @@ function InnerTable( const isCellSelected = row.getIsSelected(); if (e.shiftKey) { const { rows } = getRowModel(); - const rowsToToggle = getRowRange(rows, row.index, lastSelectedIndex.current); + const rowsToToggle = getRowRange(rows, index, lastSelectedIndex.current); setRowSelection(Object.fromEntries(rowsToToggle.map((r) => [r.id, !isCellSelected]))); } else if (e.metaKey || e.ctrlKey) { const newSelection = structuredClone(rowSelection); @@ -140,7 +140,7 @@ function InnerTable( } if (!isCellSelected) { - lastSelectedIndex.current = row.index; + lastSelectedIndex.current = index; } } : undefined