Skip to content

Commit a41bd7b

Browse files
authored
fix(core): allow pan on drag for non left-btn when selectionKeyCode is true (#1662)
* fix(core): allow pan on drag for non left-btn when selection key code is true Signed-off-by: braks <[email protected]> * fix(core): reorder pane class names Signed-off-by: braks <[email protected]> * chore(changeset): add Signed-off-by: braks <[email protected]> * chore(core): cleanup Signed-off-by: braks <[email protected]> --------- Signed-off-by: braks <[email protected]>
1 parent 94d99bf commit a41bd7b

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

.changeset/empty-falcons-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": patch
3+
---
4+
5+
Reorder pane class names to allow dragging cursor when selection mode is permanently enabled

.changeset/nasty-panthers-admire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": patch
3+
---
4+
5+
Allow pan on drag when selectionKeyCode is `true` but panOnDrag key is not left mouse btn

packages/core/src/composables/useKeyPress.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function useKeyOrCode(code: string, keysToWatch: string | string[]) {
7575
* @param keyFilter - Can be a boolean, a string, an array of strings or a function that returns a boolean. If it's a boolean, it will act as if the key is always pressed. If it's a string, it will return true if a key matching that string is pressed. If it's an array of strings, it will return true if any of the strings match a key being pressed, or a combination (e.g. ['ctrl+a', 'ctrl+b'])
7676
* @param options - Options object
7777
*/
78-
export function useKeyPress(keyFilter: MaybeRefOrGetter<KeyFilter | null>, options?: UseKeyPressOptions) {
78+
export function useKeyPress(keyFilter: MaybeRefOrGetter<KeyFilter | boolean | null>, options?: UseKeyPressOptions) {
7979
const actInsideInputWithModifier = toRef(() => toValue(options?.actInsideInputWithModifier) ?? false)
8080

8181
const target = toRef(() => toValue(options?.target) ?? window)
@@ -149,7 +149,7 @@ export function useKeyPress(keyFilter: MaybeRefOrGetter<KeyFilter | null>, optio
149149
isPressed.value = false
150150
}
151151

152-
function createKeyFilterFn(keyFilter: KeyFilter | null) {
152+
function createKeyFilterFn(keyFilter: KeyFilter | boolean | null) {
153153
// if the keyFilter is null, we just set the isPressed value to false
154154
if (keyFilter === null) {
155155
reset()

packages/core/src/style.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
cursor: grab;
2323
}
2424

25-
&.dragging {
26-
cursor: grabbing;
27-
}
28-
2925
&.selection {
3026
cursor: pointer;
3127
}
28+
29+
&.dragging {
30+
cursor: grabbing;
31+
}
3232
}
3333

3434
.vue-flow__transformationpane {

packages/core/src/types/flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export interface FlowProps {
162162
connectionRadius?: number
163163
isValidConnection?: ValidConnectionFunc | null
164164
deleteKeyCode?: KeyFilter | null
165-
selectionKeyCode?: KeyFilter | null
165+
selectionKeyCode?: KeyFilter | boolean | null
166166
multiSelectionKeyCode?: KeyFilter | null
167167
zoomActivationKeyCode?: KeyFilter | null
168168
panActivationKeyCode?: KeyFilter | null

packages/core/src/types/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export interface State extends Omit<FlowProps, 'id' | 'modelValue'> {
8383
multiSelectionActive: boolean
8484

8585
deleteKeyCode: KeyFilter | null
86-
selectionKeyCode: KeyFilter | null
86+
selectionKeyCode: KeyFilter | boolean | null
8787
multiSelectionKeyCode: KeyFilter | null
8888
zoomActivationKeyCode: KeyFilter | null
8989
panActivationKeyCode: KeyFilter | null

0 commit comments

Comments
 (0)