fix(datagrid): redraw cell when editability changes (chevron flicker on save/refresh)#1214
Merged
Merged
Conversation
…ory tracks current state
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.
Summary
DataGridCellView.computeAccessoryRectgates the chevron accessory onisEditableCellfor dropdown / boolean / date / JSON / blob cells:```swift
case .dropdown, .boolean, .date, .json, .blob:
guard isEditableCell else { return .zero }
```
After #1212's performance pass, `configure` only marks the cell `needsDisplay = true` when a tracked property changed. `isEditableCell` was updated unconditionally:
```swift
isEditableCell = state.isEditable
```
…so when only the editability flipped (refresh, safe-mode toggle, view-to-table switch) with otherwise identical cell content, no redraw was scheduled and the chevron stuck in its stale state. User saw `audit_log.payload` (LONGTEXT with `json_valid` check, detected as JSON) chevron disappear after save / refresh / reopen.
Fix
Compare before assign and flag `needsRedraw` on change:
```swift
if isEditableCell != state.isEditable {
isEditableCell = state.isEditable
needsRedraw = true
}
```
Audited the rest of `configure`. Other unconditional assignments (`placeholder`, `isLargeDataset`) are write-only fields that aren't read elsewhere, so they can't affect drawing. `cellRow` / `cellColumnIndex` only feed accessibility. The two cells that do affect drawing (text/tint/visualState/kind/rawValue/focus) were already tracked.
Test plan