Skip to content

fix(datagrid): apply Copy as and Delete to the whole cell-range selection#1898

Merged
datlechin merged 1 commit into
mainfrom
fix/copy-as-range-selection
Jul 16, 2026
Merged

fix(datagrid): apply Copy as and Delete to the whole cell-range selection#1898
datlechin merged 1 commit into
mainfrom
fix/copy-as-range-selection

Conversation

@datlechin

Copy link
Copy Markdown
Member

Problem

After a cell-range drag in the data grid, right-click > Copy as > any format copied only the active row. The rest of the range was ignored. Same bug in the context menu's Delete and the Edit menu's Copy Rows, Copy with Headers, Copy as JSON, and Delete. Cmd-clicking a column header was worse: it empties the native row selection, so those commands saw no selection at all.

Root cause

The grid keeps two selection models: the native row selection (GridSelectionState / NSTableView.selectedRowIndexes) and the cell-range selection (GridSelectionController, added in #1446). A range drag collapses the row selection to the active row on purpose, so anything reading only the row selection sees one row. Plain Copy and keyboard Delete were fixed in 0.51.1; every other action kept re-deriving the selection by hand from the row selection alone.

Fix

  • New TableViewCoordinator.currentRowSelection(fallbackRow:): range selection rows first, else the row selection, else the clicked row. This matches the AppKit contract (clickedRow inside the selection acts on all selected rows) and what DataGrip, TablePlus, Postico, and Sequel Ace do.
  • All consumers go through it: the 9 Copy as items and Delete in the grid context menu, Copy Rows and its menu validation and keyboard Delete in KeyHandlingTableView, and the Edit menu commands in MainContentCommandActions (with the old behavior as fallback when no grid is mounted). The Structure tab and the row inspector inherit the fix through the shared grid code.
  • Copy as keeps full-row output. The range only decides which rows.
  • Also fixed: the Edit menu's Copy as JSON indexed rows by raw display position, so it copied the wrong rows under an active sort or filter. It now resolves through DisplayRowMapping like its siblings.

Tests

17 new regression tests: every Copy as format and Delete driven with the exact post-drag state (range selection live, row selection collapsed to one row), the column-selection case, menu validation, display-order mapping for Copy as JSON, and the no-grid fallback.

Note: CommandActionsDispatchTests/insertQueryFromAI_appendsToExisting fails on this branch and on clean main. It expects the append behavior that #1428 replaced with open-in-new-tab. Left for a separate fix.

@datlechin
datlechin merged commit 88032b8 into main Jul 16, 2026
2 checks passed
@datlechin
datlechin deleted the fix/copy-as-range-selection branch July 16, 2026 19:27
@mintlify

mintlify Bot commented Jul 16, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🔴 Failed Jul 16, 2026, 7:27 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@mintlify

mintlify Bot commented Jul 16, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟡 Building Jul 16, 2026, 7:27 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

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.

1 participant