fix(datagrid): write row inspector edits into the rows the grid draws (#2851) - #2858
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
This branch was successfully deployed
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.
Fixes #2851.
The bug
Edit a field in the row inspector and the grid cell beside it keeps the old value. Select another row and come back and the inspector shows the old value too, as if the edit never happened. Save writes it anyway, and the value reappears after the reload. The reporter's recording on the issue shows all three.
Root cause
Two writers of one buffer, and only one of them did the whole job.
The grid's own cell commit,
TableViewCoordinator.recordCellEdit, refuses a server-owned column, records the change inDataChangeManagerkeyed byRowIDwith that row's own current value asoldValue, writes the new value into the sharedTableRowsbuffer, and repaints the cell.The inspector's
onFieldChangedclosure did only the record.TableRowsis both what the grid draws from and whatMultiRowEditState.configurerebuilds the inspector's fields from, so the edit was invisible in the grid, was dropped from the inspector on the next selection change, and surfaced only when Save wrote the change that had been staged all along.The fix
The inspector stages a cell edit through the same shape the grid does, in
RowEditingCoordinator.stageInspectorFieldEdit: writability gate, onerecordCellChangeper row with that row's own previous value, oneTableRows.editMany, one repaint.Two things that had to come with it:
RowID.MultiRowEditStatecarried display positions and the commit resolved them when the keystroke arrived, which is the invariant in CLAUDE.md that this pane already shipped once (Faulty Details for Json column #1837). The ids are captured when the selection is configured.nil, and so NULL, whenever a multi-row selection disagrees on the field.Undo granularity is unchanged and is left out deliberately. A SwiftUI
TextFieldbound to a string writes its binding per keystroke, so one typed word is still one undo step per character, as it is today. A coalescer was written, reviewed, and cut: making one run of keystrokes one step correctly needs the registered action's destination to track the run, the whole selected row set to stay in it, inserted rows to count as modified, and an editing-session boundary theonFieldChangedcallback does not carry. That is its own change, and the evidence is in the report below.Undo and redo now refresh the inspector as well.
handleUndoResultrewroteTableRowsand repainted the grid but moved nothingInspectorTriggerwatches, so the pane went on showing the value the grid had just taken back. And the inspector's JSON rendering rebuilds when you switch to it, so it cannot show the row as it was before the edit.The inspector's other writers are untouched: the pickers, Set NULL, Set DEFAULT, Set EMPTY, the SQL functions, the hex editor and the pop-out windows all reach the same
MultiRowEditStatemethods and get the new behaviour for free.Verification
verify.sh buildPASS.verify.sh testPASS overInspectorFieldEditStagingTests,DataChangeManagerTests,DataChangeManagerExtendedTests,PendingChangesRowIdentityTests,MultiRowEditStateTests,MultiRowEditStateJsonTests,FieldValueStateTests,AnyChangeManagerTests,ValueFilterEditedRowTests,RowOperationsManagerTests.swiftlint --strictoverTablePro TableProTests TableProUITests: no violations in the changed files.InspectorEditReachesGridUITeststypes into an inspector field and reads the value back out of the grid's accessibility tree.review, working tree). Its findings against the undo coalescer are why that part was cut; the two it raised against the shipped code, the comment style and the docs paragraph, are addressed.Screenshots
The before state is the reporter's screen recording on #2851. There is no scripted after shot:
#2381made the grid draw its cells with CoreText, so a data-grid row takes no synthetic click fromSystem Eventsand a screenshot of the edited state cannot be driven without XCUITest. The UI test asserts the same claim a shot would show.