diff --git a/lib/features/replace/BpmnReplace.js b/lib/features/replace/BpmnReplace.js index 7bbfdbbe..6cb4473a 100644 --- a/lib/features/replace/BpmnReplace.js +++ b/lib/features/replace/BpmnReplace.js @@ -151,6 +151,13 @@ function BpmnReplace(bpmnFactory, replace, selection, modeling, eventBus) { } } + // remove children if not expanding sub process + if (is(oldBusinessObject, 'bpmn:SubProcess') + && !isExpanded(oldBusinessObject) + && !is(newBusinessObject, 'bpmn:SubProcess')) { + hints.moveChildren = false; + } + // transform collapsed/expanded pools if (is(oldBusinessObject, 'bpmn:Participant')) { diff --git a/test/spec/features/replace/BpmnReplaceSpec.js b/test/spec/features/replace/BpmnReplaceSpec.js index 9f490e48..cadd73fa 100644 --- a/test/spec/features/replace/BpmnReplaceSpec.js +++ b/test/spec/features/replace/BpmnReplaceSpec.js @@ -853,6 +853,25 @@ describe('features/replace - bpmn replace', function() { }) ); + + it('should remove children of collapsed sub process not morphing into expanded', + inject(function(bpmnReplace, elementRegistry, modeling) { + + // given + var element = elementRegistry.get('SubProcess_1'); + var newElementData = { + type: 'bpmn:CallActivity' + }; + + modeling.toggleCollapse(element); + + // when + var newElement = bpmnReplace.replaceElement(element, newElementData); + + // then + expect(is(newElement, 'bpmn:CallActivity')).to.be.true; + })); + });