-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Check for duplicates
- I have searched for similar issues before opening a new one.
Description
When undoing the deletion of a connected block, its outer connections (ConnectionType.PREVIOUS_STATEMENT or ConnectionType.OUTPUT_VALUE) are not restored. This results in the block becoming disconnected and bumped away instead.
The issue was introduced in Blockly 12.4.0 as part of 52d935c:
Lines 294 to 302 in 52d935c
| if ( | |
| eventUtils.isEnabled() && | |
| !childConnection.getSourceBlock().isDeadOrDying() | |
| ) { | |
| event = new (eventUtils.get(EventType.BLOCK_MOVE))( | |
| childConnection.getSourceBlock(), | |
| ) as BlockMove; | |
| event.setReason(['disconnect']); | |
| } |
The added check for the block being dead or dying in Connection.disconnectInternal() prevents the BlockMove event with reason "disconnect" from being constructed and fired. This, in turn, results in it not being recorded and added to the active event group.
childConnection.getSourceBlock().isDeadOrDying() is always true in this case, as Block.disposing has already been set to true here earlier when Block.dipose() was invoked.
When undoing the deletion, the block’s outer connections are not properly restored because the disconnection event was never recorded and is thus not part of the undo stack.
Reproduction steps
- Add a
controls_ifblock to the workspace. - Add any other block to the workspace.
- Connect the block to the
controls_ifblock anywhere. - Delete the block.
- Undo once.
→ Observe that the restored block is not connected to the controls_if block.
Priority
This is a major issue, as it effectively breaks undoing most block deletions in Blockly 12.4.0 and higher.
A fix for this should be relatively straightforward and would involve improving the changes introduced to Connection.disconnectInternal() in 52d935c, while also keeping #8455 fixed.
Stack trace
Screenshots
No response
Browsers
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status