Skip to content

Commit fe435df

Browse files
fix: show correct preview during unconstrained movement near a connection
1 parent 22deadd commit fe435df

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/actions/mover.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export class Mover {
121121
this.moves.set(workspace, info);
122122
// Begin drag.
123123
dragger.onDragStart(info.fakePointerEvent('pointerdown'));
124+
info.updateTotalDelta();
124125
return true;
125126
}
126127

src/keyboard_drag_strategy.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ export class KeyboardDragStrategy extends dragging.BlockDragStrategy {
6060
// The next constrained move will resume the search from the current
6161
// candidate location.
6262
this.searchNode = ASTNode.createConnectionNode(neighbour);
63-
// The moving block will be positioned slightly down and to the
64-
// right of the connection it found.
65-
// @ts-expect-error block is private.
66-
this.block.moveDuringDrag(
67-
new utils.Coordinate(neighbour.x + 10, neighbour.y + 10),
68-
);
63+
if (this.isConstrainedMovement()) {
64+
// Position the moving block down and slightly to the right of the
65+
// target connection.
66+
// @ts-expect-error block is private.
67+
this.block.moveDuringDrag(
68+
new utils.Coordinate(neighbour.x + 10, neighbour.y + 10),
69+
);
70+
}
6971
} else {
7072
// Handle the case when unconstrained drag was far from any candidate.
7173
this.searchNode = null;

0 commit comments

Comments
 (0)