diff --git a/lib/features/modeling/behavior/SubProcessPlaneBehavior.js b/lib/features/modeling/behavior/SubProcessPlaneBehavior.js index a610e060..c4eb466e 100644 --- a/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +++ b/lib/features/modeling/behavior/SubProcessPlaneBehavior.js @@ -95,6 +95,34 @@ export default function SubProcessPlaneBehavior( }, true); + this.preExecuted('shape.replace', function(context) { + var oldShape = context.oldShape; + var newShape = context.newShape; + + if (!isCollapsedSubProcess(oldShape) || !isCollapsedSubProcess(newShape)) { + return; + } + + // old plane could have content, + // we remove it so it is not recursively deleted from 'shape.delete' + context.oldRoot = canvas.removeRootElement(planeId(oldShape)); + }, true); + + + this.postExecuted('shape.replace', function(context) { + var newShape = context.newShape, + source = context.oldRoot, + target = canvas.findRoot(planeId(newShape)); + + if (!source || !target) { + return; + } + var elements = source.children; + + modeling.moveElements(elements, { x: 0, y: 0 }, target); + }, true); + + // rename secondary elements (roots) when the primary element changes // this ensures rootElement.id = element.id + '_plane' this.executed('element.updateProperties', function(context) {