mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
fix: Drag immovable and shadow blocks along with their parent. (#9281)
This commit is contained in:
@@ -501,22 +501,32 @@ export class Block {
|
||||
// Detach this block from the parent's tree.
|
||||
this.previousConnection.disconnect();
|
||||
}
|
||||
const nextBlock = this.getNextBlock();
|
||||
if (opt_healStack && nextBlock && !nextBlock.isShadow()) {
|
||||
// Disconnect the next statement.
|
||||
const nextTarget = this.nextConnection?.targetConnection ?? null;
|
||||
nextTarget?.disconnect();
|
||||
if (
|
||||
previousTarget &&
|
||||
this.workspace.connectionChecker.canConnect(
|
||||
previousTarget,
|
||||
nextTarget,
|
||||
false,
|
||||
)
|
||||
) {
|
||||
// Attach the next statement to the previous statement.
|
||||
previousTarget.connect(nextTarget!);
|
||||
}
|
||||
|
||||
if (!opt_healStack) return;
|
||||
|
||||
// Immovable or shadow next blocks need to move along with the block; keep
|
||||
// going until we encounter a normal block or run off the end of the stack.
|
||||
let nextBlock = this.getNextBlock();
|
||||
while (nextBlock && (nextBlock.isShadow() || !nextBlock.isMovable())) {
|
||||
nextBlock = nextBlock.getNextBlock();
|
||||
}
|
||||
if (!nextBlock) return;
|
||||
|
||||
// Disconnect the next statement.
|
||||
const nextTarget =
|
||||
nextBlock.previousConnection?.targetBlock()?.nextConnection
|
||||
?.targetConnection ?? null;
|
||||
nextTarget?.disconnect();
|
||||
if (
|
||||
previousTarget &&
|
||||
this.workspace.connectionChecker.canConnect(
|
||||
previousTarget,
|
||||
nextTarget,
|
||||
false,
|
||||
)
|
||||
) {
|
||||
// Attach the next statement to the previous statement.
|
||||
previousTarget.connect(nextTarget!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user