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 <78412429+bcakmakoglu@users.noreply.github.com>

* fix(core): reorder pane class names

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

* chore(changeset): add

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

* chore(core): cleanup

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

---------

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2024-11-01 19:48:16 +01:00
parent de6f042826
commit fe552fc5c5
6 changed files with 18 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@vue-flow/core": patch
---
Reorder pane class names to allow dragging cursor when selection mode is permanently enabled
+5
View File
@@ -0,0 +1,5 @@
---
"@vue-flow/core": patch
---
Allow pan on drag when selectionKeyCode is `true` but panOnDrag key is not left mouse btn
+2 -2
View File
@@ -75,7 +75,7 @@ function useKeyOrCode(code: string, keysToWatch: string | string[]) {
* @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']) * @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'])
* @param options - Options object * @param options - Options object
*/ */
export function useKeyPress(keyFilter: MaybeRefOrGetter<KeyFilter | null>, options?: UseKeyPressOptions) { export function useKeyPress(keyFilter: MaybeRefOrGetter<KeyFilter | boolean | null>, options?: UseKeyPressOptions) {
const actInsideInputWithModifier = toRef(() => toValue(options?.actInsideInputWithModifier) ?? false) const actInsideInputWithModifier = toRef(() => toValue(options?.actInsideInputWithModifier) ?? false)
const target = toRef(() => toValue(options?.target) ?? window) const target = toRef(() => toValue(options?.target) ?? window)
@@ -149,7 +149,7 @@ export function useKeyPress(keyFilter: MaybeRefOrGetter<KeyFilter | null>, optio
isPressed.value = false isPressed.value = false
} }
function createKeyFilterFn(keyFilter: KeyFilter | null) { function createKeyFilterFn(keyFilter: KeyFilter | boolean | null) {
// if the keyFilter is null, we just set the isPressed value to false // if the keyFilter is null, we just set the isPressed value to false
if (keyFilter === null) { if (keyFilter === null) {
reset() reset()
+4 -4
View File
@@ -22,13 +22,13 @@
cursor: grab; cursor: grab;
} }
&.dragging {
cursor: grabbing;
}
&.selection { &.selection {
cursor: pointer; cursor: pointer;
} }
&.dragging {
cursor: grabbing;
}
} }
.vue-flow__transformationpane { .vue-flow__transformationpane {
+1 -1
View File
@@ -162,7 +162,7 @@ export interface FlowProps {
connectionRadius?: number connectionRadius?: number
isValidConnection?: ValidConnectionFunc | null isValidConnection?: ValidConnectionFunc | null
deleteKeyCode?: KeyFilter | null deleteKeyCode?: KeyFilter | null
selectionKeyCode?: KeyFilter | null selectionKeyCode?: KeyFilter | boolean | null
multiSelectionKeyCode?: KeyFilter | null multiSelectionKeyCode?: KeyFilter | null
zoomActivationKeyCode?: KeyFilter | null zoomActivationKeyCode?: KeyFilter | null
panActivationKeyCode?: KeyFilter | null panActivationKeyCode?: KeyFilter | null
+1 -1
View File
@@ -83,7 +83,7 @@ export interface State extends Omit<FlowProps, 'id' | 'modelValue'> {
multiSelectionActive: boolean multiSelectionActive: boolean
deleteKeyCode: KeyFilter | null deleteKeyCode: KeyFilter | null
selectionKeyCode: KeyFilter | null selectionKeyCode: KeyFilter | boolean | null
multiSelectionKeyCode: KeyFilter | null multiSelectionKeyCode: KeyFilter | null
zoomActivationKeyCode: KeyFilter | null zoomActivationKeyCode: KeyFilter | null
panActivationKeyCode: KeyFilter | null panActivationKeyCode: KeyFilter | null