From fe435df873fe790e1745595418e5ce1471a19bab Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 18 Apr 2025 15:31:43 -0700 Subject: [PATCH] fix: show correct preview during unconstrained movement near a connection --- src/actions/mover.ts | 1 + src/keyboard_drag_strategy.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/actions/mover.ts b/src/actions/mover.ts index 4d2c40e9..db19eb99 100644 --- a/src/actions/mover.ts +++ b/src/actions/mover.ts @@ -121,6 +121,7 @@ export class Mover { this.moves.set(workspace, info); // Begin drag. dragger.onDragStart(info.fakePointerEvent('pointerdown')); + info.updateTotalDelta(); return true; } diff --git a/src/keyboard_drag_strategy.ts b/src/keyboard_drag_strategy.ts index 75eea3c6..0b4b3377 100644 --- a/src/keyboard_drag_strategy.ts +++ b/src/keyboard_drag_strategy.ts @@ -60,12 +60,14 @@ export class KeyboardDragStrategy extends dragging.BlockDragStrategy { // The next constrained move will resume the search from the current // candidate location. this.searchNode = ASTNode.createConnectionNode(neighbour); - // The moving block will be positioned slightly down and to the - // right of the connection it found. - // @ts-expect-error block is private. - this.block.moveDuringDrag( - new utils.Coordinate(neighbour.x + 10, neighbour.y + 10), - ); + if (this.isConstrainedMovement()) { + // Position the moving block down and slightly to the right of the + // target connection. + // @ts-expect-error block is private. + this.block.moveDuringDrag( + new utils.Coordinate(neighbour.x + 10, neighbour.y + 10), + ); + } } else { // Handle the case when unconstrained drag was far from any candidate. this.searchNode = null;