fix: all use closest candidate when moving disconnected blocks (#9971)

* fix: all use closest candidate when moving disconnected blocks

* fix: update move commands in test
This commit is contained in:
Michael Harvey
2026-06-10 14:29:53 -04:00
committed by GitHub
parent 000aafd5ec
commit 23c08ac0af
2 changed files with 14 additions and 11 deletions
@@ -1023,12 +1023,14 @@ export class BlockDragStrategy implements IDragStrategy {
if (forwardTraversal) {
if (currentPairIndex === -1) {
const terminal = this.isInTerminalPosition(this.block, Direction.DOWN);
if (navigator.getNavigationLoops()) {
return this.pairToCandidate(pairs[0]);
} else if (!terminal) {
return this.getClosestCandidate(this.block, delta);
if (terminal) {
if (navigator.getNavigationLoops()) {
return this.pairToCandidate(pairs[0]);
} else {
return null;
}
}
return null;
return this.getClosestCandidate(this.block, delta);
} else if (currentPairIndex === pairs.length - 1) {
return null;
} else {
@@ -1037,12 +1039,14 @@ export class BlockDragStrategy implements IDragStrategy {
} else {
if (currentPairIndex === -1) {
const terminal = this.isInTerminalPosition(this.block, Direction.UP);
if (navigator.getNavigationLoops()) {
return this.pairToCandidate(pairs[pairs.length - 1]);
} else if (!terminal) {
return this.getClosestCandidate(this.block, delta);
if (terminal) {
if (navigator.getNavigationLoops()) {
return this.pairToCandidate(pairs[pairs.length - 1]);
} else {
return null;
}
}
return null;
return this.getClosestCandidate(this.block, delta);
} else if (currentPairIndex === 0) {
return null;
} else {
@@ -1282,7 +1282,6 @@ suite('Keyboard-driven movement', function () {
Blockly.getFocusManager().focusNode(loop);
startMove(this.workspace);
moveRight(this.workspace);
this.clock.tick(10);
this.moveAndAssert(