chore(label-editing): remove businessObject name on empty text
The following two actions will now unset the business objects name property: * deleting external label * entering empty text via direct editing
This commit is contained in:
parent
a7a1743df0
commit
6c081d854f
|
@ -370,6 +370,10 @@ LabelEditingProvider.prototype.update = function(
|
|||
};
|
||||
}
|
||||
|
||||
if (isEmptyText(newLabel)) {
|
||||
newLabel = null;
|
||||
}
|
||||
|
||||
this._modeling.updateLabel(element, newLabel, newBounds);
|
||||
};
|
||||
|
||||
|
@ -392,3 +396,7 @@ function isCollapsedPool(element) {
|
|||
function isExpandedPool(element) {
|
||||
return is(element, 'bpmn:Participant') && isExpanded(element);
|
||||
}
|
||||
|
||||
function isEmptyText(label) {
|
||||
return !label || !label.trim();
|
||||
}
|
|
@ -94,7 +94,7 @@ export default function LabelBehavior(
|
|||
|
||||
// check if label
|
||||
if (labelTarget && hints.unsetLabel !== false) {
|
||||
modeling.updateLabel(labelTarget, '', null, { removeShape: false });
|
||||
modeling.updateLabel(labelTarget, null, null, { removeShape: false });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -244,6 +244,38 @@ describe('features - label-editing', function() {
|
|||
});
|
||||
|
||||
|
||||
describe('should unset', function() {
|
||||
|
||||
it('name on empty text', function() {
|
||||
|
||||
// given
|
||||
var diagramElement = elementRegistry.get('SequenceFlow_1');
|
||||
|
||||
// when
|
||||
directEditActivate(diagramElement);
|
||||
directEditComplete(' ');
|
||||
|
||||
// then
|
||||
expect(diagramElement.businessObject.name).not.to.exist;
|
||||
});
|
||||
|
||||
|
||||
it('text on empty text', function() {
|
||||
|
||||
// given
|
||||
var diagramElement = elementRegistry.get('TextAnnotation_1');
|
||||
|
||||
// when
|
||||
directEditActivate(diagramElement);
|
||||
directEditComplete(' ');
|
||||
|
||||
// then
|
||||
expect(diagramElement.businessObject.text).not.to.exist;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('should trigger redraw', function() {
|
||||
|
||||
it('on shape change', function() {
|
||||
|
|
|
@ -328,7 +328,7 @@ describe('behavior - LabelBehavior', function() {
|
|||
|
||||
// then
|
||||
expect(startEventShape.label).not.to.exist;
|
||||
expect(startEvent.name).to.equal('');
|
||||
expect(startEvent.name).not.to.exist;
|
||||
}));
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue