fix(snapping): prevent participants snap to group bounds

This commit is contained in:
Niklas Kiefer 2019-05-29 08:10:34 +02:00 committed by merge-me[bot]
parent c28aa00f3d
commit 643ca2193c
4 changed files with 34 additions and 2 deletions

View File

@ -403,7 +403,7 @@ function initParticipantSnapping(context, shape, elements) {
}
var snapBox = getBoundingBox(elements.filter(function(e) {
return !e.labelTarget && !e.waypoints;
return !e.labelTarget && !e.waypoints && !is(e, 'bpmn:Group');
}));
snapBox.x -= 50;

View File

@ -14,6 +14,7 @@
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="SubProcess_1" targetRef="EndEvent_1"/>
<bpmn2:group id="Group_1" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
@ -39,6 +40,9 @@
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_2" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="562.0" y="129.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Group_1_di" bpmnElement="Group_1">
<dc:Bounds x="645" y="96" width="170" height="120" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_SubProcess_2" targetElement="_BPMNShape_EndEvent_2">
<di:waypoint xsi:type="dc:Point" x="512.0" y="147.0"/>
<di:waypoint xsi:type="dc:Point" x="562.0" y="147.0"/>

View File

@ -143,7 +143,7 @@ describe('features/modeling - create participant', function() {
// then
expect(participantShape.children.length).to.equal(0);
expect(processShape.children.length).to.equal(7);
expect(processShape.children.length).to.equal(8);
// children di is wired
expect(startEventDi.$parent).to.eql(rootShapeDi);

View File

@ -337,6 +337,34 @@ describe('features/snapping - BpmnSnapping', function() {
);
it('should not snap to group bounds',
inject(function(canvas, create, dragging, elementFactory, elementRegistry) {
// given
var participantShape = elementFactory.createParticipantShape(false),
rootElement = canvas.getRootElement(),
rootGfx = canvas.getGraphics(rootElement),
groupElement = elementRegistry.get('Group_1');
// when
create.start(canvasEvent({ x: 50, y: 50 }), participantShape);
dragging.hover({ element: rootElement, gfx: rootGfx });
dragging.move(canvasEvent({ x: 400, y: 400 }));
dragging.end(canvasEvent({ x: 400, y: 400 }));
// then
var totalWidth = groupElement.x + groupElement.width + 70,
totalHeight = groupElement.y + groupElement.height + 40;
expect(participantShape).not.to.have.bounds({
width: totalWidth, height: totalHeight, x: 100, y: 52
});
})
);
it('should snap to process children bounds / bottom right',
inject(function(canvas, create, dragging, elementFactory) {