fix(label-editing): cancel on element deletion

Closes https://github.com/bpmn-io/bpmn-js/issues/1664
This commit is contained in:
Nico Rehwaldt 2022-05-24 16:01:11 +02:00 committed by fake-join[bot]
parent c80880fa39
commit aa4b45da6c
2 changed files with 30 additions and 0 deletions

View File

@ -58,6 +58,16 @@ export default function LabelEditingProvider(
}
});
eventBus.on([
'shape.remove',
'connection.remove'
], function(event) {
if (directEditing.isActive(event.element)) {
directEditing.cancel();
}
});
// cancel on command stack changes
eventBus.on([ 'commandStack.changed' ], function(e) {
if (directEditing.isActive()) {

View File

@ -203,6 +203,26 @@ describe('features - label-editing', function() {
}
));
it('should cancel on element deletion', inject(
function(elementRegistry, directEditing, selection, modeling) {
// given
var shape = elementRegistry.get('Task_1'),
task = shape.businessObject;
directEditing.activate(shape);
directEditing._textbox.content.textContent = 'FOO BAR';
// when
modeling.removeElements([ shape ]);
// then
expect(task.name).not.to.equal('FOO BAR');
}
));
});