Skip to content

chore: next release #1796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @vue-flow/core

## 1.42.4

### Patch Changes

- [#1794](https://github.com/bcakmakoglu/vue-flow/pull/1794) [`e0bb46e`](https://github.com/bcakmakoglu/vue-flow/commit/e0bb46e9ee6c67737e40d154bbd8eae5cdde0cce) Thanks [@bcakmakoglu](https://github.com/bcakmakoglu)! - Use null as fallback id for edge source handle

- [#1796](https://github.com/bcakmakoglu/vue-flow/pull/1796) [`978b896`](https://github.com/bcakmakoglu/vue-flow/commit/978b8966468737897b6b63fd1ff38d2eee7772d9) Thanks [@bcakmakoglu](https://github.com/bcakmakoglu)! - Remove edgelookup update when updating connection lookup as edge lookup is computed already

- [#1796](https://github.com/bcakmakoglu/vue-flow/pull/1796) [`a6a3000`](https://github.com/bcakmakoglu/vue-flow/commit/a6a30008ead042f01b3dd7e82cc015cbfd4f65a2) Thanks [@bcakmakoglu](https://github.com/bcakmakoglu)! - Reset drag items on drag end

## 1.42.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue-flow/core",
"version": "1.42.3",
"version": "1.42.4",
"private": false,
"license": "MIT",
"author": "Burak Cakmakoglu<[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/Edges/EdgeWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ const EdgeWrapper = defineComponent({
updating.value = true

nodeId.value = isSourceHandle ? edge.value.target : edge.value.source
handleId.value = (isSourceHandle ? edge.value.targetHandle : edge.value.sourceHandle) ?? ''
handleId.value = (isSourceHandle ? edge.value.targetHandle : edge.value.sourceHandle) ?? null

edgeUpdaterType.value = isSourceHandle ? 'target' : 'source'

Expand Down
27 changes: 14 additions & 13 deletions packages/core/src/composables/useDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
getEventPosition,
handleNodeClick,
hasSelector,
isUseDragEvent,
snapPosition,
} from '../utils'
import { useGetPointerPosition, useVueFlow } from '.'
Expand Down Expand Up @@ -226,8 +225,10 @@ export function useDrag(params: UseDragParams) {
}

const eventEnd = (event: UseDragEvent) => {
if (!isUseDragEvent(event) && !dragStarted && !dragging.value && !multiSelectionActive.value) {
const evt = event as MouseTouchEvent
let isClick = false

if (!dragStarted && !dragging.value && !multiSelectionActive.value) {
const evt = event.sourceEvent as MouseTouchEvent

const pointerPos = getPointerPosition(evt)

Expand All @@ -238,19 +239,11 @@ export function useDrag(params: UseDragParams) {
// dispatch a click event if the node was attempted to be dragged but the threshold was not exceeded
if (distance !== 0 && distance <= nodeDragThreshold.value) {
onClick?.(evt)
isClick = true
}

return
}

dragging.value = false
autoPanStarted = false
dragStarted = false
lastPos = { x: undefined, y: undefined }

cancelAnimationFrame(autoPanId)

if (dragItems.length) {
if (dragItems.length && !isClick) {
updateNodePositions(dragItems, false, false)

const [currentNode, nodes] = getEventHandlerParams({
Expand All @@ -261,6 +254,14 @@ export function useDrag(params: UseDragParams) {

onStop({ event: event.sourceEvent, node: currentNode, nodes })
}

dragItems = []
dragging.value = false
autoPanStarted = false
dragStarted = false
lastPos = { x: undefined, y: undefined }

cancelAnimationFrame(autoPanId)
}

watch([() => toValue(disabled), el], ([isDisabled, nodeEl], _, onCleanup) => {
Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,13 @@ export function useActions(state: State, nodeLookup: ComputedRef<NodeLookup>, ed
}

const updateEdge: Actions['updateEdge'] = (oldEdge, newConnection, shouldReplaceId = true) => {
const prevEdge = findEdge(oldEdge.id)!
const prevEdge = findEdge(oldEdge.id)

if (!prevEdge) {
return false
}

const prevEdgeIndex = state.edges.indexOf(prevEdge)

const newEdge = updateEdgeAction(oldEdge, newConnection, prevEdge, shouldReplaceId, state.hooks.error.trigger)

Expand All @@ -525,7 +531,7 @@ export function useActions(state: State, nodeLookup: ComputedRef<NodeLookup>, ed
state.edges,
)

state.edges.splice(state.edges.indexOf(prevEdge), 1, validEdge)
state.edges = state.edges.map((edge, index) => (index === prevEdgeIndex ? validEdge : edge))

updateConnectionLookup(state.connectionLookup, edgeLookup.value, [validEdge])

Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/utils/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ function addConnectionToLookup(

export function updateConnectionLookup(connectionLookup: ConnectionLookup, edgeLookup: EdgeLookup, edges: GraphEdge[]) {
connectionLookup.clear()
edgeLookup.clear()

for (const edge of edges) {
const { source: sourceNode, target: targetNode, sourceHandle = null, targetHandle = null } = edge
Expand All @@ -176,8 +175,6 @@ export function updateConnectionLookup(connectionLookup: ConnectionLookup, edgeL

addConnectionToLookup('source', connection, targetKey, connectionLookup, sourceNode, sourceHandle)
addConnectionToLookup('target', connection, sourceKey, connectionLookup, targetNode, targetHandle)

edgeLookup.set(edge.id, edge)
}
}

Expand Down
Loading