Skip to content

fix(datagrid): redraw cells after Cmd+Z when editor view briefly disappears#983

Merged
datlechin merged 1 commit intomainfrom
fix/undo-cell-state-cleanup
May 4, 2026
Merged

fix(datagrid): redraw cells after Cmd+Z when editor view briefly disappears#983
datlechin merged 1 commit intomainfrom
fix/undo-cell-state-cleanup

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

After editing a cell and pressing Cmd+Z, the yellow "modified" cell background and the modified-row highlight stayed on screen, even though pendingChanges and the toolbar Save button correctly cleared. The redraw call after undo was silently dropped.

Root cause: MainEditorContentView was wiring its @State dataTabDelegate into coordinator.dataTabDelegate (a weak ref) on .onAppear, and explicitly nilling that ref on .onDisappear. SwiftUI fires onDisappear on transient lifecycle events even when the @State strong owner persists, so the wire briefly went nil between the cell edit and the Cmd+Z dispatch. handleUndoResult then walked through dataTabDelegate?.tableViewCoordinator?.invalidateCachesForUndoRedo() and got an early-out via the nil chain.

The explicit nil is unnecessary. weak var clears itself when the @State strong owner is finally deallocated on permanent view destruction. Until then the wire stays valid through hide/show cycles. Same fix protects every other coordinator method that hits dataTabDelegate?.tableViewCoordinator?... (delete, paste, duplicate, load-more, undo-insert, etc.) which were all silently no-oping on the same code path.

Test plan

  • Open any editable table tab, edit a single cell, press Cmd+Z — yellow background and row highlight clear immediately, toolbar Save stays disabled
  • Edit a cell, switch to Structure tab and back, press Cmd+Z — same as above
  • Insert a new row, edit a cell on it, press Cmd+Z twice — cell change reverts, then row insertion reverts, no stuck "inserted" stripe
  • Delete rows, undo — rows reappear, no orphan deleted-row tint

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit a7ec25a into main May 4, 2026
2 checks passed
@datlechin datlechin deleted the fix/undo-cell-state-cleanup branch May 4, 2026 07:27
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.

1 participant