feat(datagrid): resizable JSON field in the row details inspector#1850
Merged
Conversation
|
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 #1849.
Problem
The row details inspector showed JSON values in a fixed field capped at about 3 lines (
JsonEditorViewpinned.frame(minHeight: 80, maxHeight: 120), and the code editor is greedy so it always sat at the 120px cap). To read more you had to click Expand or Open in Window. There was no way to make the field taller inline, and nothing was remembered.Change
The JSON field in the inspector is now resizable. Drag the handle below it to make it taller, up to a sensible cap. The height is stored in
@AppStorageand applies to every JSON field, so it survives moving between rows and app restarts.ResizableFieldMetrics(new): pure, unit-tested clamp helper plus the JSON height range (80 to 600) and default (120, matching the current look).ResizableEditorContainer(new): reusable view that renders content at a bound height with a thin bottom drag handle. UsesDragGesturewith@GestureStatefor the live delta, commits the clamped height on end, and showsNSCursor.resizeUpDownon hover (the same cursor pattern used inERDiagramView).JsonEditorView: wraps the editor in the container and stores the height in@AppStorage("rightSidebar.jsonFieldHeight"). The editor'sSourceEditorState/SourceEditorConfigurationare untouched on resize, so marked text (IME), the undo stack, and focus are preserved. The existing Expand and Open in Window buttons stay as the keyboard/VoiceOver path and the very-large-value escape hatch.Why
@AppStorageThe inspector's
List/ForEachre-createsJsonEditorViewfor each selected row, so a plain@Stateheight would reset every time you change rows, which is the reset the issue calls out.@AppStoragere-reads the stored value on each re-creation, so the height persists across rows and launches. One shared value means multiple JSON columns resize together, matching the single resizable value area in DataGrip and DBeaver.Native basis
There is no per-view resize affordance to reuse:
.resizable()is Image-only,.pointerStyle(.frameResize:)is macOS 15+ and we target 14, andNSSplitViewis the wrong granularity for one row in a scrolling list. This follows Apple's split-view divider idiom (thin handle, min and max clamps) with aDragGesturescoped to a thin bottom strip so it does not fight the list's scroll or the text view's own mouse handling.Tests
ResizableFieldMetricsTestscovers the clamp: within range, at both bounds, and default-in-range. Verified locally with a standaloneswiftcrun (6/6 pass). The fullxcodebuild testwas not run here; please confirm on CI.Docs / CHANGELOG
docs/features/data-grid.mdx: the Cell Inspector section notes the resizable, persisted JSON field.CHANGELOG.md: Added entry under[Unreleased].