Skip to content

feat(inspector): add column header context menu to rename, insert, and delete columns#1932

Merged
datlechin merged 1 commit into
mainfrom
feat/csv-column-context-menu
Jul 21, 2026
Merged

feat(inspector): add column header context menu to rename, insert, and delete columns#1932
datlechin merged 1 commit into
mainfrom
feat/csv-column-context-menu

Conversation

@datlechin

Copy link
Copy Markdown
Member

Closes #1913.

Problem

Opening a CSV shows a data grid, but deleting a column meant hunting through the toolbar "Columns" dropdown. There was no way to right-click a column header and delete it. (Right-clicking a row and choosing Delete already worked.)

Root cause

The CSV editor's model and actions were already complete: CSVDocument/CSVRowStore handle delete, insert, and rename for columns and rows with undo, and InspectorViewController already had the @objc actions. The gap was discovery. The shared column-header context menu contributed no structural column items, so those actions were reachable only from the toolbar.

Change

Surface the existing column operations on the column-header right-click menu through the data grid's existing delegate seam:

  • New dataGridColumnStructureMenuItems(forColumn:) delegate hook, default [], so the shared grid stays generic and query/table grids are untouched.
  • TableViewCoordinator.menuNeedsUpdate appends the delegate's items, resolving the column via dataColumnIndex(from:) (the data index, not the visual position), so a reordered or hidden column can't delete the wrong one.
  • New InspectorColumnMenuBuilder builds the items once, used by both the header menu and the toolbar dropdown. This removed ~90 lines of duplicated menu construction from InspectorWindowController.

The menu is: Rename Column…, Insert Column Before, Insert Column After, Change Type (submenu), separator, Delete Column (last). No confirmation dialog; Cmd+Z undoes it. The row menu and keyboard behavior are unchanged.

Native / HIG

Matches Numbers: structural items first, Delete last after a separator, a one-level Type submenu, no keyboard shortcuts on context items, and undo instead of a confirmation dialog. macOS has no red destructive menu styling, so the items are plain. The issue cited Table Cruncher, but it actually uses buttons plus sort-on-right-click; the Numbers right-click pattern is the one users expect here.

Tests

InspectorColumnMenuBuilderTests (3 tests): action/tag wiring per column, Delete-last-after-separator ordering, and the Type submenu checkmark plus Reset. Deterministic, no NSDocument needed. Right-click row delete is unchanged and covered by the shared grid.

xcodebuild -project TablePro.xcodeproj -scheme TablePro test -skipPackagePluginValidation -only-testing:TableProTests/InspectorColumnMenuBuilder

swiftlint lint --strict is clean on the changed files.

Out of scope

The inspector's shared header menu also shows Hide Column and Filter with column, which route to unimplemented delegate methods and currently do nothing in the CSV editor. Pre-existing and separate from this change.

@datlechin
datlechin merged commit 473e506 into main Jul 21, 2026
2 checks passed
@datlechin
datlechin deleted the feat/csv-column-context-menu branch July 21, 2026 14:12
@mintlify

mintlify Bot commented Jul 21, 2026

Copy link
Copy Markdown

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

Project Status Preview Updated (UTC)
TablePro 🔴 Failed Jul 21, 2026, 2:58 PM

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

@mintlify

mintlify Bot commented Jul 21, 2026

Copy link
Copy Markdown

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

Project Status Preview Updated (UTC)
TablePro 🟡 Building Jul 21, 2026, 2:58 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.

Delete column or row in CSV

1 participant