Skip to content

Commit

Permalink
fix(outline): external label resize
Browse files Browse the repository at this point in the history
Closes #2001
  • Loading branch information
smbea authored and barmac committed Nov 3, 2023
1 parent 216b0ff commit c9f4c83
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lib/features/outline/OutlineProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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, {
Expand Down
11 changes: 7 additions & 4 deletions test/spec/features/outline/OutlineProvider.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<bpmn:dataObject id="DataObject_0usa0me" />
<bpmn:dataStoreReference id="DataStore" />
<bpmn:subProcess id="SubProcess">
<bpmn:startEvent id="Event" />
<bpmn:startEvent id="Event" name="label" />
<bpmn:task id="Task" />
<bpmn:exclusiveGateway id="Gateway" />
</bpmn:subProcess>
Expand All @@ -30,13 +30,16 @@
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0dihp8i_di" bpmnElement="Event">
<dc:Bounds x="460" y="322" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0px6pz2_di" bpmnElement="Gateway" isMarkerVisible="true">
<dc:Bounds x="665" y="315" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="466" y="365" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0b3cy2o_di" bpmnElement="Task">
<dc:Bounds x="530" y="300" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0px6pz2_di" bpmnElement="Gateway" isMarkerVisible="true">
<dc:Bounds x="665" y="315" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Group_1utiosm_di" bpmnElement="Group">
<dc:Bounds x="200" y="179" width="140" height="300" />
</bpmndi:BPMNShape>
Expand Down
40 changes: 34 additions & 6 deletions test/spec/features/outline/OutlineProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -118,17 +121,44 @@ describe('features/outline - outline provider', function() {

describe('update', function() {

describe('should update label', function() {

var DELTA = 3;

it('should update label according to label dimentions', inject(function(elementRegistry, selection, modeling) {

// given
var event = elementRegistry.get('Event');
var externalLabel = event.label;

selection.select(externalLabel);
var outlineShape = domQuery('.selected .djs-outline', outlineShape);

// then
let bounds = outlineShape.getBoundingClientRect();
expect(bounds.width).to.be.closeTo(34, DELTA);
expect(bounds.height).to.be.closeTo(24, DELTA);

// when
modeling.updateLabel(externalLabel, 'fooooooooooooooo');

// then
bounds = outlineShape.getBoundingClientRect();
expect(bounds.width).to.be.closeTo(93, DELTA);
expect(bounds.height).to.be.closeTo(37, DELTA);
}));

});


describe('should update dimensions on resize', function() {

it('sub process', inject(function(elementRegistry, outline, selection, modeling) {
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);
Expand All @@ -139,14 +169,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);
Expand Down

0 comments on commit c9f4c83

Please sign in to comment.