fix(editor): preserve multi-click selection drags
This commit is contained in:
4 files changed
+20
-19
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { startsQueryEditorRectangularSelection, usesQueryEditorObjectNavigationModifier } from "@/lib/editor/queryEditorPointerSelection";
|
||||
import { startsQueryEditorRectangularSelection, startsQueryEditorSelectionDrag, usesQueryEditorObjectNavigationModifier } from "@/lib/editor/queryEditorPointerSelection";
|
||||
|
||||
describe("query editor pointer selection", () => {
|
||||
it("starts rectangular selection for Alt+left drag", () => {
|
||||
@@ -14,6 +14,14 @@ describe("query editor pointer selection", () => {
|
||||
expect(startsQueryEditorRectangularSelection({ altKey: false, button: 0 })).toBe(false);
|
||||
});
|
||||
|
||||
it("leaves multi-click and Shift selection gestures to CodeMirror", () => {
|
||||
expect(startsQueryEditorSelectionDrag({ detail: 0, shiftKey: false })).toBe(true);
|
||||
expect(startsQueryEditorSelectionDrag({ detail: 1, shiftKey: false })).toBe(true);
|
||||
expect(startsQueryEditorSelectionDrag({ detail: 1, shiftKey: true })).toBe(false);
|
||||
expect(startsQueryEditorSelectionDrag({ detail: 2, shiftKey: false })).toBe(false);
|
||||
expect(startsQueryEditorSelectionDrag({ detail: 3, shiftKey: false })).toBe(false);
|
||||
});
|
||||
|
||||
it("uses Cmd or Ctrl without Alt for object navigation", () => {
|
||||
expect(usesQueryEditorObjectNavigationModifier({ altKey: false, ctrlKey: false, metaKey: true })).toBe(true);
|
||||
expect(usesQueryEditorObjectNavigationModifier({ altKey: false, ctrlKey: true, metaKey: false })).toBe(true);
|
||||
|
||||
@@ -3,6 +3,11 @@ export interface QueryEditorPointerEvent {
|
||||
button: number;
|
||||
}
|
||||
|
||||
export interface QueryEditorSelectionDragEvent {
|
||||
detail: number;
|
||||
shiftKey: boolean;
|
||||
}
|
||||
|
||||
export interface QueryEditorObjectNavigationModifierEvent {
|
||||
altKey: boolean;
|
||||
ctrlKey: boolean;
|
||||
@@ -13,6 +18,10 @@ export function startsQueryEditorRectangularSelection(event: QueryEditorPointerE
|
||||
return event.altKey || event.button === 1;
|
||||
}
|
||||
|
||||
export function startsQueryEditorSelectionDrag(event: QueryEditorSelectionDragEvent): boolean {
|
||||
return !event.shiftKey && event.detail <= 1;
|
||||
}
|
||||
|
||||
export function usesQueryEditorObjectNavigationModifier(event: QueryEditorObjectNavigationModifierEvent): boolean {
|
||||
return !event.altKey && (event.metaKey || event.ctrlKey);
|
||||
}
|
||||
Reference in new issue
Block a user