fix: the same row again is the same selection - #312
Merged
Merged
Conversation
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
useCueSelection'smove(index, "plain")calledsetSelected(new Set([index]))whatever the selection already was, so clicking the row that is already the only selected row handed React a new object with the same member and everything that reads the selection rendered again.setActivebeside it was already a no-op, because React compares the value.Interface-spec §7.2 asks for this outright, and says why: a redundant announcement in React is a redundant render. It was parked because it could not be proved from outside, and the instrument that would have proved it, a render counter published in the DOM, was judged heavier than the defect. That judgement is out of date: the keydown counter added earlier today is one attribute write inside an effect that already exists, and the same shape works here.
Closes N159.
Changes
How to verify by using the app
Nothing visible changes, which is the point: the grid is virtualised, so the work saved is bounded by the rows on screen. Click the row the cursor is on and nothing flickers, as before.
Verified on Linux. Full gate green, 87 spec files and 516 tests in 5:55, verdict line GATE GREEN. Proved by a mutation in the build: with the unconditional
new Set([index])back, the check readsExpected: 32, Received: 33, which is the one redundant commit this closes, counted rather than argued.