Skip to content

Commit

Permalink
feat(bendpoints): do not reconnect if source and target not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Nov 14, 2019
1 parent e96165b commit cddefe5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/features/bendpoints/BendpointMove.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
29 changes: 27 additions & 2 deletions test/spec/features/bendpoints/BendpointsMoveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
));

});


Expand Down

0 comments on commit cddefe5

Please sign in to comment.