fix(datagrid): update Details pane when a row is selected by mouse click (#1496)#1518
Merged
Merged
Conversation
…legate with an integration test
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 #1496
Problem
Clicking a row in the data grid with the mouse selected it visually but did not update the Details/Inspector pane. Only keyboard arrow navigation updated it.
Root cause
tableViewSelectionDidChangeis the AppKit hook that fires for both mouse and keyboard selection. One overloaded boolean (isSyncingSelection) gated two unrelated things in it:On a mouse click,
mouseDownset that flag to keep the cell selection it had just established. That also suppressed the binding write, so the inspector never learned the row changed. Keyboard navigation set no flag, so it worked.Fix
new != previous), the real "did the selection change" condition. Mouse and keyboard go through the identical path. The flag on this write was redundant: the programmatic sync and inspector-navigation paths already set the binding to the target first, so equality skips the write and avoids any feedback loop.isSyncingSelectiontoisApplyingProgrammaticRowSelectionto name its real, single job: do not clear the cell-range selection when a row change is applied programmatically. Updated all four call sites and the property in one change.RowSelectionSyncDecisionhelper so the asymmetry is explicit and unit-testable.Tests
New
RowSelectionSyncDecisionTestscovers the regression directly: the row-binding write happens for a changed selection even during a programmatic mouse selection (the case the old code got wrong), and the cell-selection clear is suppressed only for programmatic selection.Verification
swiftlint lint --strict: 0 violations on all changed files.