Rules and canConnect behavior

Hi,

I defined a CustomRule to allow connections between elements or not.
In this example, I want to allow the connection between the Business Actor element and the Business Interface element, and not with the Note element but I’m a bit amazed at the behavior of canConnect: the direction of the arrow is changed when I point to the Note element instead of having the red icon. It seems like source and target are reversed.

ezgif.com-gif-maker

function canConnect(source, target) {
  if (!source || !target ) {
    return false;
  }

  // VIEW is canvas element
  if (source.type === VIEW || target.type === VIEW) {
    return false;
  }

  // if target is a Note element, then no connection allowed
  if (is(target.businessObject, 'archimate:Note')) {
        return false;
  } else { 
        return { type: 'Association' };
  }

Thank you for enlightening me.

You should ensure that you don’t want to allow target-> and source->target connections. The default behaviour reverses the connection if it’s allowed.