From 3222e979ffc03c8f407c4d5d5d50d5b4dad04ec6 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 3 Apr 2023 09:19:34 +0200 Subject: [PATCH] fix(core): use fallback for connectable start and end Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --- .../core/src/components/Handle/Handle.vue | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/core/src/components/Handle/Handle.vue b/packages/core/src/components/Handle/Handle.vue index 82f6b228..6ec9e5cc 100644 --- a/packages/core/src/components/Handle/Handle.vue +++ b/packages/core/src/components/Handle/Handle.vue @@ -21,8 +21,15 @@ const emits = defineEmits<{ const type = toRef(props, 'type', 'source') -const { connectionStartHandle, connectionClickStartHandle, connectionEndHandle, vueFlowRef, nodesConnectable, noDragClassName } = - useVueFlow() +const { + connectionStartHandle, + connectionClickStartHandle, + connectionEndHandle, + vueFlowRef, + nodesConnectable, + noDragClassName, + noPanClassName, +} = useVueFlow() const { id: nodeId, node, nodeEl, connectedEdges } = useNode() @@ -30,6 +37,10 @@ const handle = ref() const handleId = computed(() => id ?? `${nodeId}__handle-${position}`) +const isConnectableStart = computed(() => (typeof connectableStart !== 'undefined' ? connectableStart : true)) + +const isConnectableEnd = computed(() => (typeof connectableEnd !== 'undefined' ? connectableEnd : true)) + const { handlePointerDown, handleClick } = useHandle({ nodeId, handleId, @@ -107,7 +118,7 @@ until(() => node.initialized) function onPointerDown(event: MouseEvent | TouchEvent) { const isMouseTriggered = isMouseEvent(event) - if (isConnectable.value && connectableStart && ((isMouseTriggered && event.button === 0) || !isMouseTriggered)) { + if (isConnectable.value && isConnectableStart.value && ((isMouseTriggered && event.button === 0) || !isMouseTriggered)) { handlePointerDown(event) } @@ -119,7 +130,7 @@ function onPointerDown(event: MouseEvent | TouchEvent) { } function onClick(event: MouseEvent) { - if (!nodeId || (!connectionStartHandle && !connectableStart)) { + if (!nodeId || (!connectionStartHandle.value && !isConnectableStart.value)) { return } @@ -148,13 +159,14 @@ export default { `vue-flow__handle-${position}`, `vue-flow__handle-${handleId}`, noDragClassName, + noPanClassName, type, { connectable: isConnectable, connecting: isClickConnecting, - connectablestart: connectableStart, - connectableend: connectableEnd, - connectionindicator: isConnectable && ((connectableStart && !isConnecting) || (connectableEnd && isConnecting)), + connectablestart: isConnectableStart, + connectableend: isConnectableEnd, + connectionindicator: isConnectable && ((isConnectableStart && !isConnecting) || (isConnectableEnd && isConnecting)), }, ]" @mousedown="onPointerDown"