Repository navigation
Description
Severity: P1 (data safety). This is data loss in the released 1.3.0: after sorting or filtering the grid, "Delete Row" deletes a different row from the one you clicked.
What happens
Reproduction on http://localhost:1420/?mock=connected:
- Run
SELECT * FROM orders. - Click the
statuscolumn header to sort ascending. The third row on screen is nowid21 (customer_id 946). - Right-click that row and choose Copy Cell on the customer_id column. The clipboard holds
844, which is id 3's value, while the cell on screen shows946. Copy 1 row as JSON likewise gives the row with"id": 3. - Click Edit Mode, right-click the same row (id 21) and choose Delete Row. Row id 21 is struck through.
- Click Save Changes (1). The statement sent to the backend is:
The toast says "Applied 1 change(s)". Row id 21 is still there; row id 3 is gone.
DELETE FROM `orders` WHERE `id` = 3 AND `customer_id` = 844 AND `status` = 'pending' ... LIMIT 1;
The same mismatch applies to Set NULL, Copy Row, every "Copy N rows as ..." item, and the edited/deleted row highlight. All of them use the row's position on screen, but look the data up by its position in the unsorted result.
Cause
src/components/grid/GridRows.tsx:192-206(and the virtualized copy at:120-136) pass the display index (rowIdxfromtable.getRowModel().rows.map((row, rowIdx) => ...)) toclickRow,handleRowContextMenu,editing.isRowDeletedandediting.isRowEdited.src/hooks/useGridContextMenu.tsx:44,103,108andsrc/hooks/useGridExport.ts:83-87then readresult.rows[rowIdx]and callediting.deleteRow(rowIdx)with that display index.- Cell edits use
row.index, the original data index (src/hooks/useGridColumns.tsx:60), so edits land on the right row while context-menu actions and copies do not.
Fix
Pass row.index instead of the display position to selection, the context menu, delete, Set NULL and the row highlight, and key the selection by data index. Add a test that sorts, deletes the row at display position N, and asserts the generated DELETE targets that row.
Part of #783.
Activity
fix(grid): act on clicked row after sort or filter
release: 1.4.0 (#871)