From 23c08ac0afc5e1ffbd0933697e10025155f4fc02 Mon Sep 17 00:00:00 2001 From: Michael Harvey <43474485+mikeharv@users.noreply.github.com> Date: Wed, 10 Jun 2026 14:29:53 -0400 Subject: [PATCH] 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 --- .../core/dragging/block_drag_strategy.ts | 24 +++++++++++-------- .../tests/mocha/keyboard_movement_test.js | 1 - 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/blockly/core/dragging/block_drag_strategy.ts b/packages/blockly/core/dragging/block_drag_strategy.ts index b86ae8b97..82272d3e7 100644 --- a/packages/blockly/core/dragging/block_drag_strategy.ts +++ b/packages/blockly/core/dragging/block_drag_strategy.ts @@ -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 { diff --git a/packages/blockly/tests/mocha/keyboard_movement_test.js b/packages/blockly/tests/mocha/keyboard_movement_test.js index eb47f64b7..07828aecf 100644 --- a/packages/blockly/tests/mocha/keyboard_movement_test.js +++ b/packages/blockly/tests/mocha/keyboard_movement_test.js @@ -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(