Skip to content
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

chore: next release #1796

Merged
merged 4 commits into from
Mar 17, 2025
Merged
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
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<78412429+bcakmakoglu@users.noreply.github.com>",
2 changes: 1 addition & 1 deletion packages/core/src/components/Edges/EdgeWrapper.ts
Original file line number Diff line number Diff line change
@@ -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'

27 changes: 14 additions & 13 deletions packages/core/src/composables/useDrag.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import {
getEventPosition,
handleNodeClick,
hasSelector,
isUseDragEvent,
snapPosition,
} from '../utils'
import { useGetPointerPosition, useVueFlow } from '.'
@@ -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)

@@ -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({
@@ -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) => {
10 changes: 8 additions & 2 deletions packages/core/src/store/actions.ts
Original file line number Diff line number Diff line change
@@ -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)

@@ -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])

3 changes: 0 additions & 3 deletions packages/core/src/utils/store.ts
Original file line number Diff line number Diff line change
@@ -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
@@ -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)
}
}


Unchanged files with check annotations Beta

*
* @public
* @returns a vue flow store instance
* @param idOrOpts - id of the store instance or options to create a new store instance

Check warning on line 22 in packages/core/src/composables/useVueFlow.ts

GitHub Actions / build-and-test (ubuntu-latest, 20)

Expected @param names to be "id". Got "idOrOpts"
*/
export function useVueFlow(id?: string): VueFlowStore
export function useVueFlow(options?: FlowOptions): VueFlowStore
*
* @public
* @param nodeId - The id (or ids) of the node to get the data from
* @param guard - Optional guard function to narrow down the node type

Check warning on line 18 in packages/core/src/composables/useNodesData.ts

GitHub Actions / build-and-test (ubuntu-latest, 20)

@param "guard" does not match an existing function parameter
* @returns An array of data objects
*/
export function useNodesData<NodeType extends Node = GraphNode>(
*
* @public
* @param edgeId - The id (or ids) of the node to get the data from
* @param guard - Optional guard function to narrow down the node type

Check warning on line 18 in packages/core/src/composables/useEdgesData.ts

GitHub Actions / build-and-test (ubuntu-latest, 20)

@param "guard" does not match an existing function parameter
* @returns An array of data objects
*/
export function useEdgesData<EdgeType extends Edge = GraphEdge>(