Skip to content

Commit 23c08ac

Browse files
authored
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
1 parent 000aafd commit 23c08ac

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

packages/blockly/core/dragging/block_drag_strategy.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,12 +1023,14 @@ export class BlockDragStrategy implements IDragStrategy {
10231023
if (forwardTraversal) {
10241024
if (currentPairIndex === -1) {
10251025
const terminal = this.isInTerminalPosition(this.block, Direction.DOWN);
1026-
if (navigator.getNavigationLoops()) {
1027-
return this.pairToCandidate(pairs[0]);
1028-
} else if (!terminal) {
1029-
return this.getClosestCandidate(this.block, delta);
1026+
if (terminal) {
1027+
if (navigator.getNavigationLoops()) {
1028+
return this.pairToCandidate(pairs[0]);
1029+
} else {
1030+
return null;
1031+
}
10301032
}
1031-
return null;
1033+
return this.getClosestCandidate(this.block, delta);
10321034
} else if (currentPairIndex === pairs.length - 1) {
10331035
return null;
10341036
} else {
@@ -1037,12 +1039,14 @@ export class BlockDragStrategy implements IDragStrategy {
10371039
} else {
10381040
if (currentPairIndex === -1) {
10391041
const terminal = this.isInTerminalPosition(this.block, Direction.UP);
1040-
if (navigator.getNavigationLoops()) {
1041-
return this.pairToCandidate(pairs[pairs.length - 1]);
1042-
} else if (!terminal) {
1043-
return this.getClosestCandidate(this.block, delta);
1042+
if (terminal) {
1043+
if (navigator.getNavigationLoops()) {
1044+
return this.pairToCandidate(pairs[pairs.length - 1]);
1045+
} else {
1046+
return null;
1047+
}
10441048
}
1045-
return null;
1049+
return this.getClosestCandidate(this.block, delta);
10461050
} else if (currentPairIndex === 0) {
10471051
return null;
10481052
} else {

packages/blockly/tests/mocha/keyboard_movement_test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,6 @@ suite('Keyboard-driven movement', function () {
12821282

12831283
Blockly.getFocusManager().focusNode(loop);
12841284
startMove(this.workspace);
1285-
moveRight(this.workspace);
12861285
this.clock.tick(10);
12871286

12881287
this.moveAndAssert(

0 commit comments

Comments
 (0)