|
2 | 2 | import { ref, toRef, watch } from 'vue'
|
3 | 3 | import UserSelection from '../../components/UserSelection/UserSelection.vue'
|
4 | 4 | import NodesSelection from '../../components/NodesSelection/NodesSelection.vue'
|
5 |
| -import { type GraphNode, SelectionMode } from '../../types' |
| 5 | +import { SelectionMode } from '../../types' |
6 | 6 | import { useKeyPress, useVueFlow } from '../../composables'
|
7 | 7 | import { getConnectedEdges, getNodesInside } from '../../utils'
|
8 | 8 | import { getMousePosition } from './utils'
|
@@ -54,28 +54,11 @@ watch(deleteKeyPressed, (isKeyPressed) => {
|
54 | 54 | return
|
55 | 55 | }
|
56 | 56 |
|
57 |
| - const nodesToRemove: GraphNode[] = [] |
58 |
| - for (const node of getNodes.value) { |
59 |
| - if (!node.selected && node.parentNode && nodesToRemove.some((n) => n.id === node.parentNode)) { |
60 |
| - nodesToRemove.push(node) |
61 |
| - } else if (node.selected) { |
62 |
| - nodesToRemove.push(node) |
63 |
| - } |
64 |
| - } |
65 |
| -
|
66 |
| - if (nodesToRemove || getSelectedEdges.value) { |
67 |
| - if (getSelectedEdges.value.length > 0) { |
68 |
| - removeEdges(getSelectedEdges.value) |
69 |
| - } |
| 57 | + removeNodes(getSelectedNodes.value) |
70 | 58 |
|
71 |
| - if (nodesToRemove.length > 0) { |
72 |
| - removeNodes(nodesToRemove) |
73 |
| - } |
| 59 | + removeEdges(getSelectedEdges.value) |
74 | 60 |
|
75 |
| - nodesSelectionActive.value = false |
76 |
| -
|
77 |
| - removeSelectedElements() |
78 |
| - } |
| 61 | + nodesSelectionActive.value = false |
79 | 62 | })
|
80 | 63 |
|
81 | 64 | watch(multiSelectKeyPressed, (isKeyPressed) => {
|
@@ -125,17 +108,14 @@ function onWheel(event: WheelEvent) {
|
125 | 108 | }
|
126 | 109 |
|
127 | 110 | function onPointerDown(event: PointerEvent) {
|
| 111 | + if (!hasActiveSelection.value) { |
| 112 | + return emits.paneMouseMove(event) |
| 113 | + } |
| 114 | +
|
128 | 115 | containerBounds.value = vueFlowRef.value?.getBoundingClientRect()
|
129 | 116 | container.value?.setPointerCapture(event.pointerId)
|
130 | 117 |
|
131 |
| - if ( |
132 |
| - !hasActiveSelection.value || |
133 |
| - !elementsSelectable || |
134 |
| - !isSelecting || |
135 |
| - event.button !== 0 || |
136 |
| - event.target !== container.value || |
137 |
| - !containerBounds.value |
138 |
| - ) { |
| 118 | + if (!elementsSelectable || !isSelecting || event.button !== 0 || event.target !== container.value || !containerBounds.value) { |
139 | 119 | return
|
140 | 120 | }
|
141 | 121 |
|
@@ -198,12 +178,16 @@ function onPointerMove(event: PointerEvent) {
|
198 | 178 | }
|
199 | 179 |
|
200 | 180 | function onPointerUp(event: PointerEvent) {
|
201 |
| - if (!hasActiveSelection.value || event.button !== 0) { |
| 181 | + if (event.button !== 0) { |
202 | 182 | return
|
203 | 183 | }
|
204 | 184 |
|
205 | 185 | container.value?.releasePointerCapture(event.pointerId)
|
206 | 186 |
|
| 187 | + if (!hasActiveSelection.value) { |
| 188 | + return |
| 189 | + } |
| 190 | +
|
207 | 191 | // We only want to trigger click functions when in selection mode if
|
208 | 192 | // the user did not move the mouse.
|
209 | 193 | if (!userSelectionActive.value && userSelectionRect.value && event.target === container.value) {
|
|
0 commit comments