fix(modeling): do not resize label target when setting empty label

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
This commit is contained in:
Nico Rehwaldt 2020-03-27 23:55:44 +01:00 committed by fake-join[bot]
parent 9c114de26a
commit 960a085d4c
2 changed files with 26 additions and 5 deletions

View File

@ -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) {
@ -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

View File

@ -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(