cancelConnectionDrag method

void cancelConnectionDrag()

Cancels a connection drag without creating a connection.

Call this from PortWidget's GestureDetector.onPanEnd when not over a valid target, or from onPanCancel when the gesture is interrupted.

Implementation

void cancelConnectionDrag() {
  // Reset highlighted port before canceling
  final temp = interaction.temporaryConnection.value;
  if (temp != null &&
      temp.targetNodeId != null &&
      temp.targetPortId != null) {
    final targetNode = _nodes[temp.targetNodeId!];
    if (targetNode != null) {
      final targetPort = targetNode.allPorts
          .where((p) => p.id == temp.targetPortId)
          .firstOrNull;
      if (targetPort != null) {
        runInAction(() => targetPort.highlighted.value = false);
      }
    }
  }

  interaction.cancelConnection();

  // Note: Canvas unlocking is now handled by DragSession

  events.connection?.onConnectEnd?.call(null, null);
}