Skip to content

Make the grid context menu act on the clicked row after sort or filter #839

Closed

Description

@EVWorth

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:

  1. Run SELECT * FROM orders.
  2. Click the status column header to sort ascending. The third row on screen is now id 21 (customer_id 946).
  3. 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 shows 946. Copy 1 row as JSON likewise gives the row with "id": 3.
  4. Click Edit Mode, right-click the same row (id 21) and choose Delete Row. Row id 21 is struck through.
  5. Click Save Changes (1). The statement sent to the backend is:
    DELETE FROM `orders` WHERE `id` = 3 AND `customer_id` = 844 AND `status` = 'pending' ... LIMIT 1;
    The toast says "Applied 1 change(s)". Row id 21 is still there; row id 3 is gone.

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 (rowIdx from table.getRowModel().rows.map((row, rowIdx) => ...)) to clickRow, handleRowContextMenu, editing.isRowDeleted and editing.isRowEdited.
  • src/hooks/useGridContextMenu.tsx:44,103,108 and src/hooks/useGridExport.ts:83-87 then read result.rows[rowIdx] and call editing.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

  1. added
    bug
    on Oct 21, 2026
  2. added a commit that references this issue on Oct 23, 2026
    98ba422
  3. added a commit that references this issue on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions