diff --git a/lib/features/ordering/BpmnOrderingProvider.js b/lib/features/ordering/BpmnOrderingProvider.js
index f7330627..f302172f 100644
--- a/lib/features/ordering/BpmnOrderingProvider.js
+++ b/lib/features/ordering/BpmnOrderingProvider.js
@@ -131,7 +131,7 @@ export default function BpmnOrderingProvider(eventBus, canvas, translate) {
// render labels always on top
if (element.labelTarget) {
return {
- parent: canvas.findRoot(element.labelTarget) || canvas.getRootElement(),
+ parent: canvas.findRoot(newParent) || canvas.getRootElement(),
index: -1
};
}
diff --git a/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviour.bpmn b/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviour.bpmn
index db4ad5ad..b36794a7 100644
--- a/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviour.bpmn
+++ b/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviour.bpmn
@@ -60,15 +60,15 @@
SequenceFlow_10
-
+
SequenceFlow_10
SequenceFlow_11
-
+
SequenceFlow_11
-
+
@@ -150,7 +150,7 @@
-
+
@@ -170,11 +170,12 @@
+
-
+
diff --git a/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js b/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js
index 0455bb02..c932382e 100644
--- a/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js
+++ b/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js
@@ -360,6 +360,30 @@ describe('features/modeling - collapse and expand elements', function() {
);
+ it('moves all children to plane',
+ inject(function(elementRegistry, bpmnReplace) {
+
+ // given
+ var expandedSubProcess = elementRegistry.get('SubProcess_2');
+ var originalChildren = expandedSubProcess.children.slice();
+
+ // when
+ bpmnReplace.replaceElement(expandedSubProcess,
+ {
+ type: 'bpmn:SubProcess',
+ isExpanded: false
+ }
+ );
+
+ // then
+ var plane = elementRegistry.get('SubProcess_2_plane');
+ originalChildren.forEach(function(c) {
+ expect(plane.children).to.include(c);
+ });
+ })
+ );
+
+
describe('resize', function() {
it('is centered and has default bounds',