feat(datagrid): copy focused cell value with Cmd+C, add Cmd+Shift+C for rows (#1332)#1337
Merged
Conversation
… so Cmd+Shift+C enables in structure tab
…update selectionState
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1332.
Cmd+Cin the data grid now copies the focused cell value when a single row is selected and a cell has focus on a data column. Otherwise it copies the selected row(s) as TSV (existing behavior).Cmd+Shift+Cis a new shortcut that always copies the selected row(s) as TSV, even when a cell is focused. "Copy with Headers" stays in the Edit menu and right-click menu but loses its default shortcut.Why
The data grid renders a cell focus border and tracks
focusedRow/focusedColumn, butCmd+Cignored both and always copied the whole row. Foreign key cells were the worst-affected case: double-click opens the FK popover instead of inline edit, so users had no keyboard path to copy just the cell value.This aligns the shortcut with what the UI shows. Apple's HIG and most database clients (DataGrip, DBeaver, Postico, Sequel Ace, MySQL Workbench) target the most specific visible selection. TablePlus uses
Cmd+Shift+Cfor explicit-rows, which this PR matches.Implementation
Native AppKit responder chain:
KeyHandlingTableView.copy(_:)decides cell vs row internally based onfocusedDataCell()(mirrors the existingpaste(_:)pattern at the same call site).KeyHandlingTableView.copyRowsAsTSV(_:)is a new selector for explicit-row dispatch.PasteboardCommandsmenu buttons dispatch viaNSApp.sendAction(_, to: nil, from: nil), letting the responder chain delivercopy:to NSTextView or the table view.PasteboardActionRouterstays in its original 3-case form (text / rows / table-names). The sidebar table-names case still routes via app state because the sidebar may not be in the responder chain.PasteboardCommandsnow gets aCommandActionsRegistryfallback for@FocusedValue, matchingAppMenuCommands. Without it,.disabled(!hasRowSelection)was always true when NSTableView was first responder, which disabled the "Copy Rows" menu item and blocked the shortcut.AppCommands.copySelectedRowsobserver routes throughcopySelectedRows()so the structure-tab guard applies.Test plan
xcodebuild -project TablePro.xcodeproj -scheme TablePro test -skipPackagePluginValidation -only-testing:TableProTests/PasteboardActionRouterTestsCmd+C-> clipboard contains only the cell valueCmd+C-> clipboard contains the raw FK valueCmd+C-> clipboard contains TSV of all selected rowsCmd+Shift+C-> clipboard contains the row as TSV (not the cell)Cmd+C-> clipboard contains the row TSVCmd+C-> standard text copy still worksCmd+C-> table names copiedCmd+Shift+C), "Copy with Headers" (no shortcut), "Copy as JSON" with correct enabled/disabled statesCmd+Con a single focused cell copies cell value