mirror of
https://github.com/google/blockly.git
synced 2026-06-11 13:45:14 +02:00
fix: Improve fallback for getInitialCandidate (#9941)
* fix: Improve fallback for getInitialCandidate * Improve variable name
This commit is contained in:
@@ -1238,6 +1238,19 @@ export class BlockDragStrategy implements IDragStrategy {
|
||||
return this.pairToCandidate(parentPair);
|
||||
}
|
||||
|
||||
// Fall back to the nearest parent block that has a compatible connection.
|
||||
// This handles the case where a nested value block (e.g. a number input)
|
||||
// has passive focus but the dragged block is a statement block that should
|
||||
// be inserted after the containing statement block.
|
||||
let parentBlock = passiveBlock.getSurroundParent();
|
||||
while (parentBlock) {
|
||||
const pair = this.allConnectionPairs.find(
|
||||
(pair) => pair.neighbour.getSourceBlock() === parentBlock,
|
||||
);
|
||||
if (pair) return this.pairToCandidate(pair);
|
||||
parentBlock = parentBlock.getSurroundParent();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user