Skip to content

Commit 798faf1

Browse files
committed
refactor(core): remove connectedEdges from node mouse events (#1464)
* refactor(core): remove `connectedEdges` from node mouse events * chore(changeset): add
1 parent 0825101 commit 798faf1

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

.changeset/three-ants-impress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": minor
3+
---
4+
5+
Remove `connectedEdges` as arg from NodeMouseEvents

packages/core/src/components/Nodes/NodeWrapper.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ const NodeWrapper = defineComponent({
3737
compatConfig: { MODE: 3 },
3838
props: ['id', 'resizeObserver'],
3939
setup(props: Props) {
40-
provide(NodeId, props.id)
41-
4240
const {
4341
id: vueFlowId,
4442
noPanClassName,
@@ -64,16 +62,17 @@ const NodeWrapper = defineComponent({
6462
nodesFocusable,
6563
} = useVueFlow()
6664

65+
const nodeElement = ref<HTMLDivElement | null>(null)
66+
provide(NodeRef, nodeElement)
67+
provide(NodeId, props.id)
68+
6769
const slots = inject(Slots)
6870

6971
const instance = getCurrentInstance()
7072

7173
const updateNodePositions = useUpdateNodePositions()
7274

73-
const { node, parentNode, connectedEdges } = useNode(props.id)
74-
75-
const nodeElement = ref<HTMLDivElement | null>(null)
76-
provide(NodeRef, nodeElement)
75+
const { node, parentNode } = useNode(props.id)
7776

7877
const isDraggable = toRef(() => (typeof node.draggable === 'undefined' ? nodesDraggable.value : node.draggable))
7978

@@ -333,28 +332,28 @@ const NodeWrapper = defineComponent({
333332

334333
function onMouseEnter(event: MouseEvent) {
335334
if (!dragging?.value) {
336-
emit.mouseEnter({ event, node, connectedEdges: connectedEdges.value })
335+
emit.mouseEnter({ event, node })
337336
}
338337
}
339338

340339
function onMouseMove(event: MouseEvent) {
341340
if (!dragging?.value) {
342-
emit.mouseMove({ event, node, connectedEdges: connectedEdges.value })
341+
emit.mouseMove({ event, node })
343342
}
344343
}
345344

346345
function onMouseLeave(event: MouseEvent) {
347346
if (!dragging?.value) {
348-
emit.mouseLeave({ event, node, connectedEdges: connectedEdges.value })
347+
emit.mouseLeave({ event, node })
349348
}
350349
}
351350

352351
function onContextMenu(event: MouseEvent) {
353-
return emit.contextMenu({ event, node, connectedEdges: connectedEdges.value })
352+
return emit.contextMenu({ event, node })
354353
}
355354

356355
function onDoubleClick(event: MouseEvent) {
357-
return emit.doubleClick({ event, node, connectedEdges: connectedEdges.value })
356+
return emit.doubleClick({ event, node })
358357
}
359358

360359
function onSelectNode(event: MouseEvent) {
@@ -370,7 +369,7 @@ const NodeWrapper = defineComponent({
370369
)
371370
}
372371

373-
emit.click({ event, node, connectedEdges: connectedEdges.value })
372+
emit.click({ event, node })
374373
}
375374

376375
function onKeyDown(event: KeyboardEvent) {

packages/core/src/types/hooks.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { EventHookOn, EventHookTrigger } from '@vueuse/core'
22
import type { D3ZoomEvent } from 'd3-zoom'
3-
import type { VueFlowError } from '../utils/errors'
4-
import type { EventHookExtended } from '../utils/createExtendedEventHook'
3+
import type { EventHookExtended, VueFlowError } from '../utils'
54
import type { GraphEdge } from './edge'
65
import type { GraphNode } from './node'
76
import type { Connection, OnConnectStartParams } from './connection'
@@ -14,7 +13,6 @@ export type MouseTouchEvent = MouseEvent | TouchEvent
1413
export interface NodeMouseEvent {
1514
event: MouseTouchEvent
1615
node: GraphNode
17-
connectedEdges: GraphEdge[]
1816
}
1917

2018
export interface NodeDragEvent {

0 commit comments

Comments
 (0)