Skip to content

Commit 32ce6b1

Browse files
sadmann7cursoragent
andcommitted
fix(data-grid): exclude non-navigable columns from copy operation
When copying cells after selecting rows via checkbox, the copy operation was including the "select" column (and other non-navigable columns) in the TSV output. This caused an empty leading column in the clipboard data, which then shifted all pasted values by one column when pasting. The fix: 1. Skips non-navigable columns (select, actions) during iteration in serializeCellsToTsv 2. Builds a navigableCells array as we iterate (more efficient than filtering afterward) 3. Returns navigableCells for accurate cell counts in toast messages and cutCells state Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a7c4e8d commit 32ce6b1

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/hooks/use-data-grid.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,18 @@ function useDataGrid<TData>({
560560
number,
561561
Map<string, ReturnType<Row<TData>["getVisibleCells"]>[number]>
562562
>();
563+
const navigableCells: string[] = [];
563564

564565
for (const cellKey of selectedCellsArray) {
565566
const { rowIndex, columnId } = parseCellKey(cellKey);
567+
568+
// Skip non-navigable columns (like "select", "actions")
569+
if (columnId && NON_NAVIGABLE_COLUMN_IDS.has(columnId)) {
570+
continue;
571+
}
572+
573+
// Track navigable cells for accurate counts
574+
navigableCells.push(cellKey);
566575

567576
if (columnId && !seenColumnIds.has(columnId)) {
568577
seenColumnIds.add(columnId);
@@ -598,7 +607,7 @@ function useDataGrid<TData>({
598607
}
599608

600609
const colIndices = new Set<number>();
601-
for (const cellKey of selectedCellsArray) {
610+
for (const cellKey of navigableCells) {
602611
const { columnId } = parseCellKey(cellKey);
603612
const colIndex = selectedColumnIds.indexOf(columnId);
604613
if (colIndex >= 0) {
@@ -621,7 +630,7 @@ function useDataGrid<TData>({
621630
)
622631
.join("\n");
623632

624-
return { tsvData, selectedCellsArray };
633+
return { tsvData, selectedCellsArray: navigableCells };
625634
}, [store]);
626635

627636
const onCellsCopy = React.useCallback(async () => {

0 commit comments

Comments
 (0)