Connection line snaps from the shape when moving that shape

I have an XML layout from an older application that contains coordinates for the shapes and connecting lines. I’ve made a C# script that translates this XML layout into a BPMN layout. The result is below

<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="" xmlns:bpmn2="" xmlns:bpmndi="" xmlns:bioc="" xmlns:color="" xmlns:di="" xmlns:dc="" xmlns:Custom="" xmlns:platform="http://platform/schema/bpmn/platform" id="Definitions_Process_37" targetNamespace="" exporter="bpmn-js (" exporterVersion="9.0.0-alpha.2">
  <bpmn2:process id="Process_37">
    <bpmn2:intermediateThrowEvent id="Action_273612917" name="ActionName" Custom:ActionId="79">
    <bpmn2:sequenceFlow id="FlowEndpoint_161" sourceRef="Action_273612917" targetRef="Status_140" Custom:TransitionId="161" Custom:TransitionStartId="109" Custom:IsActive="True" Custom:IsEndPoint="true" />
    <bpmn2:task id="Status_140" name="StatusName" Custom:StatusId="140">
  <bpmndi:BPMNDiagram id="BPMNDiagram_Process_37">
    <bpmndi:BPMNPlane id="BPMNPlane_37" bpmnElement="Process_37">
      <bpmndi:BPMNEdge id="FlowEndpoint_161_di" bpmnElement="FlowEndpoint_161" bioc:stroke="#000000" color:border-color="#000000">
        <di:waypoint x="209" y="211" />
        <di:waypoint x="443" y="110" />
      <bpmndi:BPMNShape id="Action_273612917_di" bpmnElement="Action_273612917" bioc:stroke="#000000" color:border-color="#000000">
        <dc:Bounds x="175" y="184" width="36" height="36" />
          <dc:Bounds x="153" y="220" width="81" height="27" />
      <bpmndi:BPMNShape id="Status_140_di" bpmnElement="Status_140">
        <dc:Bounds x="443" y="90" width="154" height="40" />

Everything is ok, if I load it into BPMN it does so without any error, like in the picture below.


My issue is the following: When I try to move the task shape (StatusName) , the connection line “snaps” outside the shape, like in the picture below.


I’ve downloaded the layout generated by the BPMN website and, except some coordinates changes, I could not find anything different. The connection ends where shape starts, both in my layout and the BPMN layout. If I place the connection manually on BPMN canvas, it won’t snap out of place again.
I’ve tried setting some offsets (200 units for X-axis, and 100 units for Y-axis) on my layout, but it didn’t help.

Does anyone have any idea what is causing this issue?


After some trial and error , I found what was the problem: Bpmn Task shape has a fixed width and height (100 x 80 ) . The shapes from the old layout had various dimensions , which were transferred to the BPMN layout.
Since the dimensions where not OK, the connection snap was faulty. Once I made all the task shapes to be 100x80, the connection snap is done correctly when moving the elements.