@@ -46,7 +46,8 @@ const edgeIdLookup = ref<Map<string, Set<string>>>(new Map())
46
46
const hasActiveSelection = toRef (() => elementsSelectable .value && (isSelecting || userSelectionActive .value ))
47
47
48
48
// Used to prevent click events when the user lets go of the selectionKey during a selection
49
- const selectionInProgress = ref (false )
49
+ let selectionInProgress = false
50
+ let selectionStarted = false
50
51
51
52
const deleteKeyPressed = useKeyPress (deleteKeyCode , { actInsideInputWithModifier: false })
52
53
@@ -87,8 +88,8 @@ function resetUserSelection() {
87
88
}
88
89
89
90
function onClick(event : MouseEvent ) {
90
- if (selectionInProgress . value ) {
91
- selectionInProgress . value = false
91
+ if (selectionInProgress ) {
92
+ selectionInProgress = false
92
93
return
93
94
}
94
95
@@ -128,6 +129,8 @@ function onPointerDown(event: PointerEvent) {
128
129
129
130
const { x, y } = getMousePosition (event , containerBounds .value )
130
131
132
+ selectionStarted = true
133
+ selectionInProgress = false
131
134
edgeIdLookup .value = new Map ()
132
135
133
136
for (const [id, edge] of edgeLookup .value ) {
@@ -157,7 +160,7 @@ function onPointerMove(event: PointerEvent) {
157
160
return
158
161
}
159
162
160
- selectionInProgress . value = true
163
+ selectionInProgress = true
161
164
162
165
const { x : mouseX, y : mouseY } = getEventPosition (event , containerBounds .value )
163
166
const { startX = 0 , startY = 0 } = userSelectionRect .value
@@ -212,7 +215,7 @@ function onPointerMove(event: PointerEvent) {
212
215
}
213
216
214
217
function onPointerUp(event : PointerEvent ) {
215
- if (event .button !== 0 ) {
218
+ if (event .button !== 0 || ! selectionStarted ) {
216
219
return
217
220
}
218
221
@@ -235,8 +238,10 @@ function onPointerUp(event: PointerEvent) {
235
238
// If the user kept holding the selectionKey during the selection,
236
239
// we need to reset the selectionInProgress, so the next click event is not prevented
237
240
if (selectionKeyPressed ) {
238
- selectionInProgress . value = false
241
+ selectionInProgress = false
239
242
}
243
+
244
+ selectionStarted = false
240
245
}
241
246
</script >
242
247
0 commit comments