How can I override the fixConnection method in ReplaceConnectionBehavior?

Would really appreciate some help here… I’ve been trying to get this to work for many hours without success.

Basically my current task is to configure a custom moduler that allows bpmn:SequenceFlow connections between any and all elements without any restrictions, including connecting elements that are inside subProcess containers and those that are not. We understand this is not bpmn compliant but this is what I’ve been asked to deliver.

Allowing the connections to happen was easy enough and only required a very small custom rule.

The problem is that whenver a connected element is moved, the connection disapears. I’ve traced this to the fixConnection method that is called inside of a elements.move hook inside the ReplaceConnectionBehavior.js file.

I have tried many different ways to override this behaviour by creating custom modules and I have not been successful.

My latest attempt looks like this:

import inherits from 'inherits';
import ReplaceConnectionBehavior from 'bpmn-js/lib/features/modeling/behavior/ReplaceConnectionBehavior';

function CustomReplaceConnectionBehavior(eventBus, modeling, bpmnRules, injector) {, eventBus, modeling, bpmnRules, injector);

  // Override the postExecuted hook for 'elements.move'
    function (context) {
      console.log('elements.move', context);

      var closure = context.closure,
        allConnections = closure.allConnections;

      // Your custom logic here
      // For example, you can iterate over allConnections and apply your own logic
      // without calling fixConnection

inherits(CustomReplaceConnectionBehavior, ReplaceConnectionBehavior);

CustomReplaceConnectionBehavior.$inject = ['eventBus', 'modeling', 'bpmnRules', 'injector'];

export default {
  __init__: ['customReplaceConnectionBehavior'],
  customReplaceConnectionBehavior: ['type', CustomReplaceConnectionBehavior],

In other attempts I have tried overriding the fixConneciton method itself. That also didn’t work.

In the above example… my custom elements.move hook is indeed called, however later on when I manually move around elements in my diagram, the original elements.move hook is called, which calls the fixConnection method and removes all connections.

Can anyone tell me how I can get this to work please? Even if I have to remove all rules related to allowing or disallowing connections in order to make the connection remain unchanged when I move elements around. That would still be great.

Many many thanks…