@@ -1515,22 +1515,27 @@ export class BlockSvg
15151515 * or an insertion marker.
15161516 *
15171517 * @param sourceConnection The connection on the moving block's stack.
1518- * @param targetConnection The connection that should stay stationary as this
1519- * block is positioned.
1518+ * @param originalOffsetToTarget The connection original offset to the target connection
1519+ * @param originalOffsetInBlock The connection original offset in its block
15201520 * @internal
15211521 */
15221522 positionNearConnection (
15231523 sourceConnection : RenderedConnection ,
1524- targetConnection : RenderedConnection ,
1524+ originalOffsetToTarget : { x : number ; y : number } ,
1525+ originalOffsetInBlock : Coordinate ,
15251526 ) {
15261527 // We only need to position the new block if it's before the existing one,
15271528 // otherwise its position is set by the previous block.
15281529 if (
15291530 sourceConnection . type === ConnectionType . NEXT_STATEMENT ||
15301531 sourceConnection . type === ConnectionType . INPUT_VALUE
15311532 ) {
1532- const dx = targetConnection . x - sourceConnection . x ;
1533- const dy = targetConnection . y - sourceConnection . y ;
1533+ // First move the block to match the orginal target connection position
1534+ let dx = originalOffsetToTarget . x ;
1535+ let dy = originalOffsetToTarget . y ;
1536+ // Then adjust its position according to the connection resize
1537+ dx += originalOffsetInBlock . x - sourceConnection . getOffsetInBlock ( ) . x ;
1538+ dy += originalOffsetInBlock . y - sourceConnection . getOffsetInBlock ( ) . y ;
15341539
15351540 this . moveBy ( dx , dy ) ;
15361541 }
0 commit comments