Skip to content

Commit a839e99

Browse files
fix: show correct preview during unconstrained movement near a connection (RaspberryPiFoundation#454)
1 parent 05ff1bd commit a839e99

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
@@ -140,6 +140,7 @@ export class Mover {
140140
this.moves.set(workspace, info);
141141
// Begin drag.
142142
dragger.onDragStart(info.fakePointerEvent('pointerdown'));
143+
info.updateTotalDelta();
143144
return true;
144145
}
145146

src/keyboard_drag_strategy.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ export class KeyboardDragStrategy extends dragging.BlockDragStrategy {
6868
// The next constrained move will resume the search from the current
6969
// candidate location.
7070
this.searchNode = ASTNode.createConnectionNode(neighbour);
71-
// The moving block will be positioned slightly down and to the
72-
// right of the connection it found.
73-
// @ts-expect-error block is private.
74-
this.block.moveDuringDrag(
75-
new utils.Coordinate(neighbour.x + 10, neighbour.y + 10),
76-
);
71+
if (this.isConstrainedMovement()) {
72+
// Position the moving block down and slightly to the right of the
73+
// target connection.
74+
// @ts-expect-error block is private.
75+
this.block.moveDuringDrag(
76+
new utils.Coordinate(neighbour.x + 10, neighbour.y + 10),
77+
);
78+
}
7779
} else {
7880
// Handle the case when unconstrained drag was far from any candidate.
7981
this.searchNode = null;

0 commit comments

Comments
 (0)