I create custom element base on bpmn-io (https://github.com/bpmn-io/bpmn-js-examples/tree/master/custom-elements) However, The sequence flow which attach to custom element will be got lost when I move position of element which attached by this sequence flow.
Note: In CustomRule.canConnect function, I use bpmn:SequenceFlow instead of custom:connection
See gif for more detail.
Anyone know the reason?
There is another canConnect()-Function in the BpmnRules() class called: canConnectSequenceFlow()
You must override this method in your CustomRules class and add your own CustomConnection into this canConnectSequenceFlow() method, otherwise your connection will be deleted when you move your CustomElement, because all connections are being validated after a movement. When this connection is not “allowed”, it will be deleted!
It’s seem canConnectSequenceFlow() in BpmnRules was called from ReplaceConnectionHehavios, so, my override canConnectSequenceFlow in my CustomRules is not effected.
As you can see in the custom elements example connections are not lost on elements move. What changes did you make to the example? I see you enabled having sequence flows connecting BPMN elements to custom elements. How did you implement this?
You are right, the canConnectSequenceFlow() is located in the ReplaceConnectionBehavior!!
Did you fix the problem?
My first suggestion is to create your own CustomReplaceConnectionBehaviour and override the canConnectSequenceFlow OR you could create your own “CustomConnection”