Skip to content

Commit

Permalink
fix(modeling): do not resize label target when setting empty label
Browse files Browse the repository at this point in the history
This prevents a bug that cause the label target to be accidentally
resized if the user updates the label value to an empty string (or null).

Closes #1294
  • Loading branch information
nikku authored and fake-join[bot] committed Mar 30, 2020
1 parent 9c114de commit 960a085
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/features/label-editing/cmd/UpdateLabelHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ export default function UpdateLabelHandler(modeling, textRenderer) {
newBounds = ctx.newBounds,
hints = ctx.hints || {};

// ignore internal labels for elements except text annotations
if (!isLabel(label) && !is(label, 'bpmn:TextAnnotation')) {
return;
}

if (isLabel(label) && isEmptyText(newLabel)) {

if (hints.removeShape !== false) {
Expand All @@ -97,11 +102,6 @@ export default function UpdateLabelHandler(modeling, textRenderer) {
return;
}

// ignore internal labels for elements except text annotations
if (!isLabelExternal(element) && !is(element, 'bpmn:TextAnnotation')) {
return;
}

var text = getLabel(label);

// resize element based on label _or_ pre-defined bounds
Expand Down
21 changes: 21 additions & 0 deletions test/spec/features/modeling/UpdateLabelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ describe('features/modeling - update label', function() {
));


it('should not create label on empty text', inject(
function(modeling, elementRegistry) {

// given
var startEvent_2 = elementRegistry.get('StartEvent_2');

// when
modeling.updateLabel(startEvent_2, '');

// then
expect(startEvent_2.businessObject.name).to.equal('');
expect(startEvent_2.label).not.to.exist;

expect(startEvent_2).to.have.dimensions({
width: 36,
height: 36
});
}
));


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

it('when setting null', inject(
Expand Down

0 comments on commit 960a085

Please sign in to comment.