diff --git a/lib/features/modeling/behavior/LabelBehavior.js b/lib/features/modeling/behavior/LabelBehavior.js index 99b405c6..43241c64 100644 --- a/lib/features/modeling/behavior/LabelBehavior.js +++ b/lib/features/modeling/behavior/LabelBehavior.js @@ -209,8 +209,15 @@ export default function LabelBehavior( 'connection.layout', 'connection.updateWaypoints' ], function(event) { + var context = event.context, + hints = context.hints || {}; - var label = event.context.connection.label, + if (hints.labelBehavior === false) { + return; + } + + var connection = context.connection, + label = connection.label, labelAdjustment; // handle missing label as well as the case diff --git a/test/spec/features/modeling/behavior/LabelBehavior.bpmn b/test/spec/features/modeling/behavior/LabelBehavior.bpmn index c8e4f239..d147d105 100644 --- a/test/spec/features/modeling/behavior/LabelBehavior.bpmn +++ b/test/spec/features/modeling/behavior/LabelBehavior.bpmn @@ -1,5 +1,5 @@ - + @@ -7,6 +7,13 @@ + + SequenceFlow_1 + + + SequenceFlow_1 + + foo @@ -68,6 +75,19 @@ + + + + + + + + + + + + + diff --git a/test/spec/features/modeling/behavior/LabelBehaviorSpec.js b/test/spec/features/modeling/behavior/LabelBehaviorSpec.js index 46fce5ea..6190f777 100644 --- a/test/spec/features/modeling/behavior/LabelBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/LabelBehaviorSpec.js @@ -13,6 +13,8 @@ import { } from 'lib/util/LabelUtil'; import { + assign, + map, pick } from 'min-dash'; @@ -412,6 +414,28 @@ describe('behavior - LabelBehavior', function() { } )); + + it('should NOT move label if labelBehavior=false', inject(function(elementRegistry, modeling) { + + // given + var connection = elementRegistry.get('SequenceFlow_1'), + waypoints = copyWaypoints(connection), + label = connection.label, + oldLabelPosition = pick(label, [ 'x', 'y' ]); + + var newWaypoints = [ + waypoints[ 0 ], + { x: 0, y: 0 }, + waypoints[ 1 ] + ]; + + // when + modeling.updateWaypoints(connection, newWaypoints, { labelBehavior: false }); + + // then + expect(pick(label, [ 'x', 'y' ])).to.eql(oldLabelPosition); + })); + }); }); @@ -772,6 +796,23 @@ describe('behavior - LabelBehavior', function() { // helpers ////////// +function copyWaypoint(waypoint) { + return assign({}, waypoint); +} + +function copyWaypoints(connection) { + return map(connection.waypoints, function(waypoint) { + + waypoint = copyWaypoint(waypoint); + + if (waypoint.original) { + waypoint.original = copyWaypoint(waypoint.original); + } + + return waypoint; + }); +} + function getBounds(element) { return pick(element, [ 'x', 'y', 'width', 'height' ]); }