Position correctly when inserting before another block (from the flyout) #2415
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
Previously the block stack would move to 100, 100 on the workspace if the new block was being inserted at the start.
Proposed Changes
Use the same code that we use to solve this problem for insertion markers.
I moved the helper function and changed its signature because it had an unnecessary param before. That's the first commit. The second commit uses it.
Remove extra
connect
calls ininsertBlock
--connect
moves theorphanBlock
around internally.Reason for Changes
Blocks need to stay in the same place as new blocks are connected.
Test Coverage
Tested in the playground.
Additional information
I had to add a call to
render
so that the new block's connection positions are correct internally. That I expected. I also had to explicitly set the connections to not be hidden, which I didn't expect. The connections are hidden indomToBlock
and unhidden in a timeout, for speed when creating large block stacks. But if the connections are still hidden when I move the block, Erik's new code in #2003 makes the child block disappear.