From ed3bf2fff4166a9c7926cd6540827021c30fa7cc Mon Sep 17 00:00:00 2001 From: Beatriz Mendes Date: Thu, 2 Nov 2023 16:05:04 +0100 Subject: [PATCH] fix(outline): external label resize Closes #2001 --- lib/features/outline/OutlineProvider.js | 7 +++- .../features/outline/OutlineProvider.bpmn | 11 ++++-- .../features/outline/OutlineProviderSpec.js | 38 +++++++++++++++---- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/lib/features/outline/OutlineProvider.js b/lib/features/outline/OutlineProvider.js index 381a9ff8b1..2e206cdc17 100644 --- a/lib/features/outline/OutlineProvider.js +++ b/lib/features/outline/OutlineProvider.js @@ -75,7 +75,8 @@ OutlineProvider.prototype.getOutline = function(element) { height: element.height - 4, }, OUTLINE_STYLE)); - } else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Group' ])) { + } else if ( + isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Group' ])) { outline = svgCreate('rect'); svgAttr(outline, assign({ @@ -125,6 +126,10 @@ OutlineProvider.prototype.getOutline = function(element) { */ OutlineProvider.prototype.updateOutline = function(element, outline) { + if (isLabel(element)) { + return; + } + if (isAny(element, [ 'bpmn:SubProcess', 'bpmn:Group' ])) { svgAttr(outline, { diff --git a/test/spec/features/outline/OutlineProvider.bpmn b/test/spec/features/outline/OutlineProvider.bpmn index f9c3a1799d..08172ab8f9 100644 --- a/test/spec/features/outline/OutlineProvider.bpmn +++ b/test/spec/features/outline/OutlineProvider.bpmn @@ -9,7 +9,7 @@ - + @@ -30,13 +30,16 @@ - - - + + + + + + diff --git a/test/spec/features/outline/OutlineProviderSpec.js b/test/spec/features/outline/OutlineProviderSpec.js index 939b8d747d..3484f3f199 100644 --- a/test/spec/features/outline/OutlineProviderSpec.js +++ b/test/spec/features/outline/OutlineProviderSpec.js @@ -14,6 +14,9 @@ import { DATA_STORE_REFERENCE_OUTLINE_PATH } from 'lib/features/outline/OutlineUtil'; +import { + query as domQuery +} from 'min-dom'; describe('features/outline - outline provider', function() { var testModules = [ @@ -118,17 +121,40 @@ describe('features/outline - outline provider', function() { describe('update', function() { + describe('should update label', function() { + + it('should update label according to label dimentions', inject(function(elementRegistry, selection, modeling) { - describe('should update dimensions on resize', function() { + // given + var event = elementRegistry.get('Event'); + var externalLabel = event.label; - it('sub process', inject(function(elementRegistry, outline, selection, modeling) { + selection.select(externalLabel); + var outlineShape = domQuery('.selected .djs-outline', outlineShape); + + // then + expect(outlineShape.getAttribute('width')).to.eql('34'); + expect(outlineShape.getAttribute('height')).to.eql('24'); + + // when + modeling.updateLabel(externalLabel, 'fooooooooooooooo'); + + // then + expect(outlineShape.getAttribute('width')).to.eql('93'); + expect(outlineShape.getAttribute('height')).to.eql('37'); + })); + + }); + + + describe.only('should update dimensions on resize', function() { + + it('sub process', inject(function(elementRegistry, outline, modeling) { // given var subProcess = elementRegistry.get('SubProcess'); var outlineShape = outline.getOutline(subProcess); - selection.select(subProcess); - // when modeling.resizeShape(subProcess, { x: 339, y: 142, width: 250, height: 250 }); outline.updateShapeOutline(outlineShape, subProcess); @@ -139,14 +165,12 @@ describe('features/outline - outline provider', function() { })); - it('group', inject(function(elementRegistry, outline, selection, modeling) { + it('group', inject(function(elementRegistry, outline, modeling) { // given var group = elementRegistry.get('Group'); var outlineShape = outline.getOutline(group); - selection.select(group); - // when modeling.resizeShape(group, { x: 339, y: 142, width: 250, height: 250 }); outline.updateShapeOutline(outlineShape, group);