mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-22 13:48:16 +00:00
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:
parent
9c114de26a
commit
960a085d4c
@ -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
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user