fix: Select replacement for selected shadow block. #2457
Merged
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.
The basics
The details
Resolves
Fixes #2426
Proposed Changes
The shadow block converter plugin now detects if the shadow block being replaced was selected, and if so, it selects the block that took the place of the shadow block.
Reason for Changes
This maintains apparent continuity of the selection when a selected shadow block is edited by the user and replaced with a real block by the shadow block converter plugin.
Note that prior to google/blockly#8172 clicking on a shadow block actually selected the parent block, and this selection was maintained even if the shadow block was deleted.
After google/blockly#8172 clicking on a shadow block selects that shadow block. This means that if the shadow block is deleted, then the selection is cleared, which could be unexpected in the case of the shadow block converter plugin. This PR fixes that.
See also google/blockly#8533 which addresses the visual glitches described in #2426
Test Coverage
I added a unit test method for the new behavior.