From 87b4f7cab80ab039837b998895688e3bbdafeb30 Mon Sep 17 00:00:00 2001 From: Abdul Ahad Date: Mon, 30 Sep 2024 10:23:43 +0200 Subject: [PATCH] fix: flow text alignment issue when placed text annotation Closes #2239 --- .../AdaptiveLabelPositioningBehavior.js | 5 + ...aptiveLabelPositioningBehavior.basics.bpmn | 96 +++++++++++++------ .../AdaptiveLabelPositioningBehaviorSpec.js | 16 ++++ 3 files changed, 88 insertions(+), 29 deletions(-) diff --git a/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js b/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js index 138e098909..8acfd80079 100644 --- a/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js +++ b/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js @@ -15,6 +15,7 @@ import { } from '../../../util/LabelUtil'; import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor'; +import { isConnection } from 'diagram-js/lib/util/ModelUtil'; /** * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus @@ -99,6 +100,10 @@ export default function AdaptiveLabelPositioningBehavior(eventBus, modeling) { return; } + if (isConnection(element)) { + return; + } + var optimalPosition = getOptimalPosition(element); // no optimal position found diff --git a/test/spec/features/modeling/behavior/AdaptiveLabelPositioningBehavior.basics.bpmn b/test/spec/features/modeling/behavior/AdaptiveLabelPositioningBehavior.basics.bpmn index 6f07fb2a6a..1b0972183b 100644 --- a/test/spec/features/modeling/behavior/AdaptiveLabelPositioningBehavior.basics.bpmn +++ b/test/spec/features/modeling/behavior/AdaptiveLabelPositioningBehavior.basics.bpmn @@ -1,5 +1,5 @@ - + @@ -45,6 +45,17 @@ SequenceFlow_3 + + Flow_167deqo + + + Flow_167deqo + + + + foo + + @@ -57,7 +68,7 @@ - + @@ -90,6 +101,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -104,15 +158,6 @@ - - - - - - - - - @@ -141,34 +186,27 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/test/spec/features/modeling/behavior/AdaptiveLabelPositioningBehaviorSpec.js b/test/spec/features/modeling/behavior/AdaptiveLabelPositioningBehaviorSpec.js index be90933345..7ae150f78a 100644 --- a/test/spec/features/modeling/behavior/AdaptiveLabelPositioningBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/AdaptiveLabelPositioningBehaviorSpec.js @@ -224,6 +224,22 @@ describe('modeling/behavior - AdaptiveLabelPositioningBehavior', function() { }); + describe('on annotation move / layout', function() { + + it('should not move label', inject(function(elementRegistry, modeling) { + + // given + var source = elementRegistry.get('Flow_167deqo'), + target = elementRegistry.get('TextAnnotation_1vnawwd'); + + modeling.moveElements([ target ], { x: -110, y: 20 }); + + // then + expectLabelOrientation(source, 'top'); + })); + + }); + describe('on waypoints update', function() {