Performance: Simplify return value of multi-selection selected selector #3173
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.
Related: #3171, #3170, #3172
This pull request seeks to optimize the rendering of individual blocks when selection occurs. Currently, any time a selection is made, including for a single block, the
isSelected
prop changes for every block such that it incurs a render on all blocks. Since this change is often from two equivalent states for most blocks (null
tofalse
, and vice-versa), the changes here seek to simplify the return value of the selector for determining whether a single block is selected to simply returnfalse
when a multi-selection exists (instead ofnull
). This prevents renders except in the blocks included in the multi-selection.Implementation notes:
The documented behavior of the
isBlockSelected
was opposite that of its implementation. Both documentation and tests have been updated to reflect what appears to be the intended behavior, but verification would be appreciated.Testing instructions:
Verify there are no regressions in the behavior of block multi-selection.