fix(ordering): use specified parent when moving labels

closes #1617
This commit is contained in:
Martin Stamm 2022-03-15 17:26:03 +01:00
parent 5addfd28b3
commit 06d6f986ab
3 changed files with 31 additions and 6 deletions

View File

@ -131,7 +131,7 @@ export default function BpmnOrderingProvider(eventBus, canvas, translate) {
// render labels always on top // render labels always on top
if (element.labelTarget) { if (element.labelTarget) {
return { return {
parent: canvas.findRoot(element.labelTarget) || canvas.getRootElement(), parent: canvas.findRoot(newParent) || canvas.getRootElement(),
index: -1 index: -1
}; };
} }

View File

@ -60,15 +60,15 @@
<bpmn2:startEvent id="StartEvent_3"> <bpmn2:startEvent id="StartEvent_3">
<bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing>
</bpmn2:startEvent> </bpmn2:startEvent>
<bpmn2:task id="Task_2"> <bpmn2:task id="Task_2" name="internal label">
<bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing>
</bpmn2:task> </bpmn2:task>
<bpmn2:endEvent id="EndEvent_4"> <bpmn2:endEvent id="EndEvent_4" name="external label">
<bpmn2:incoming>SequenceFlow_11</bpmn2:incoming> <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming>
</bpmn2:endEvent> </bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow_10" sourceRef="StartEvent_3" targetRef="Task_2" /> <bpmn2:sequenceFlow id="SequenceFlow_10" sourceRef="StartEvent_3" targetRef="Task_2" />
<bpmn2:sequenceFlow id="SequenceFlow_11" sourceRef="Task_2" targetRef="EndEvent_4" /> <bpmn2:sequenceFlow id="SequenceFlow_11" name="connection label" sourceRef="Task_2" targetRef="EndEvent_4" />
</bpmn2:adHocSubProcess> </bpmn2:adHocSubProcess>
<bpmn2:subProcess id="SubProcess_5"> <bpmn2:subProcess id="SubProcess_5">
<bpmn2:startEvent id="StartEvent_6" /> <bpmn2:startEvent id="StartEvent_6" />
@ -150,7 +150,7 @@
<di:waypoint x="625" y="437" /> <di:waypoint x="625" y="437" />
<di:waypoint x="683" y="437" /> <di:waypoint x="683" y="437" />
<bpmndi:BPMNLabel> <bpmndi:BPMNLabel>
<dc:Bounds x="609" y="412" width="90" height="20" /> <dc:Bounds x="614" y="419" width="80" height="14" />
</bpmndi:BPMNLabel> </bpmndi:BPMNLabel>
</bpmndi:BPMNEdge> </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0gkhyqw_di" bpmnElement="SequenceFlow_10"> <bpmndi:BPMNEdge id="SequenceFlow_0gkhyqw_di" bpmnElement="SequenceFlow_10">
@ -170,11 +170,12 @@
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1y93al0_di" bpmnElement="Task_2"> <bpmndi:BPMNShape id="Task_1y93al0_di" bpmnElement="Task_2">
<dc:Bounds x="525" y="397" width="100" height="80" /> <dc:Bounds x="525" y="397" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_1bmhzoz_di" bpmnElement="EndEvent_4"> <bpmndi:BPMNShape id="EndEvent_1bmhzoz_di" bpmnElement="EndEvent_4">
<dc:Bounds x="683" y="419" width="36" height="36" /> <dc:Bounds x="683" y="419" width="36" height="36" />
<bpmndi:BPMNLabel> <bpmndi:BPMNLabel>
<dc:Bounds x="656" y="455" width="90" height="20" /> <dc:Bounds x="668" y="462" width="66" height="14" />
</bpmndi:BPMNLabel> </bpmndi:BPMNLabel>
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SubProcess_0qs6p1k_di" bpmnElement="SubProcess_5" isExpanded="false"> <bpmndi:BPMNShape id="SubProcess_0qs6p1k_di" bpmnElement="SubProcess_5" isExpanded="false">

View File

@ -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() { describe('resize', function() {
it('is centered and has default bounds', it('is centered and has default bounds',