feat(inspector): add column header context menu to rename, insert, and delete columns#1932
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
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/CSVRowStorehandle delete, insert, and rename for columns and rows with undo, andInspectorViewControlleralready had the@objcactions. 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:
dataGridColumnStructureMenuItems(forColumn:)delegate hook, default[], so the shared grid stays generic and query/table grids are untouched.TableViewCoordinator.menuNeedsUpdateappends the delegate's items, resolving the column viadataColumnIndex(from:)(the data index, not the visual position), so a reordered or hidden column can't delete the wrong one.InspectorColumnMenuBuilderbuilds the items once, used by both the header menu and the toolbar dropdown. This removed ~90 lines of duplicated menu construction fromInspectorWindowController.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, noNSDocumentneeded. Right-click row delete is unchanged and covered by the shared grid.swiftlint lint --strictis 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.