From 1cb64baeb9db47443409fb93196adcff8a8006a7 Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Wed, 13 Nov 2019 22:23:05 +0100 Subject: [PATCH] feat(bendpoints): do not reconnect if source and target not changed --- lib/features/bendpoints/BendpointMove.js | 5 ++++ .../features/bendpoints/BendpointsMoveSpec.js | 29 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/features/bendpoints/BendpointMove.js b/lib/features/bendpoints/BendpointMove.js index ff4bfce70..805e6bbae 100644 --- a/lib/features/bendpoints/BendpointMove.js +++ b/lib/features/bendpoints/BendpointMove.js @@ -186,6 +186,11 @@ export default function BendpointMove(injector, eventBus, canvas, dragging, rule } } + // do NOT reconnect if both source and target haven't changed + if (source === connection.source && target === connection.target) { + return; + } + modeling.reconnect(connection, source, target, docking, hints); } }, this); diff --git a/test/spec/features/bendpoints/BendpointsMoveSpec.js b/test/spec/features/bendpoints/BendpointsMoveSpec.js index 180d25cb0..034885f4d 100755 --- a/test/spec/features/bendpoints/BendpointsMoveSpec.js +++ b/test/spec/features/bendpoints/BendpointsMoveSpec.js @@ -432,7 +432,7 @@ describe('features/bendpoints - move', function() { // given bendpointMove.start(canvasEvent({ x: 500, y: 500 }), connection, 2); - dragging.hover({ element: shape2, gfx: canvas.getGraphics(shape2) }); + dragging.hover({ element: shape5, gfx: canvas.getGraphics(shape5) }); dragging.move(canvasEvent({ x: 530, y: 120 })); // when @@ -449,7 +449,7 @@ describe('features/bendpoints - move', function() { // given bendpointMove.start(canvasEvent({ x: 500, y: 500 }), connection, 0); - dragging.hover({ element: shape1, gfx: canvas.getGraphics(shape1) }); + dragging.hover({ element: shape4, gfx: canvas.getGraphics(shape4) }); dragging.move(canvasEvent({ x: 230, y: 120 })); // when @@ -477,6 +477,31 @@ describe('features/bendpoints - move', function() { ]); })); + + it('should NOT reconnect if source and target have not changed', inject( + function(bendpointMove, canvas, dragging, modeling) { + + // given + var firstBendpointIndex = 0, + firstBendpoint = connection.waypoints[ firstBendpointIndex ], + source = connection.source; + + var reconnectSpy = spy(modeling, 'reconnect'); + + // when + bendpointMove.start(canvasEvent(firstBendpoint), connection, firstBendpointIndex); + + dragging.hover({ element: source, gfx: canvas.getGraphics(source) }); + + dragging.move(canvasEvent(getMid(source))); + + dragging.end(); + + // then + expect(reconnectSpy).not.to.have.been.called; + } + )); + });