feat(grid): add configurable shortcut to focus WHERE condition
This commit is contained in:
27 files changed
+325
No files matched your search
@@ -6,6 +6,7 @@ import {
|
||||
isEditTableStructureShortcut,
|
||||
isExecuteSqlInNewResultTabShortcut,
|
||||
isGoToColumnShortcut,
|
||||
isFocusWhereShortcut,
|
||||
isGoToFirstPageShortcut,
|
||||
isGoToLastPageShortcut,
|
||||
isGoToNextPageShortcut,
|
||||
@@ -20,6 +21,14 @@ import { formatShortcutDisplay, isMacShortcutPlatform } from "@/lib/editor/short
|
||||
import { shortcutToCodeMirrorKey } from "@/lib/editor/shortcutRegistry";
|
||||
|
||||
describe("keyboard shortcut matching", () => {
|
||||
it("matches configured WHERE focus on macOS and Windows while respecting a cleared binding", () => {
|
||||
expect(isFocusWhereShortcut({ key: "L", metaKey: true, shiftKey: true }, { focusWhere: "Mod+Shift+L" }, "MacIntel")).toBe(true);
|
||||
expect(isFocusWhereShortcut({ key: "L", ctrlKey: true, shiftKey: true }, { focusWhere: "Mod+Shift+L" }, "Win32")).toBe(true);
|
||||
expect(isFocusWhereShortcut({ key: "L", ctrlKey: true, shiftKey: true }, { focusWhere: "" }, "Win32")).toBe(false);
|
||||
expect(isFocusWhereShortcut({ key: "L", ctrlKey: true, shiftKey: true }, undefined, "Win32")).toBe(false);
|
||||
expect(isFocusWhereShortcut({ key: "L", metaKey: true, shiftKey: true }, undefined, "MacIntel")).toBe(false);
|
||||
});
|
||||
|
||||
it("records modifier-only mouse shortcut settings", () => {
|
||||
expect(eventToModifierOnlyShortcut({ key: "Alt", altKey: true })).toBe("Alt");
|
||||
expect(eventToModifierOnlyShortcut({ key: "Shift", shiftKey: true })).toBe("Shift");
|
||||
|
||||
@@ -82,6 +82,16 @@ describe("shortcutRegistry editor actions", () => {
|
||||
expect(findShortcutConflict("goToFirstPage", "Mod+F", shortcuts)).toBeNull();
|
||||
});
|
||||
|
||||
it("leaves focus-WHERE unassigned for new and existing settings and detects grid conflicts", () => {
|
||||
expect(DEFAULT_SHORTCUT_SETTINGS.focusWhere).toBe("");
|
||||
expect(normalizeShortcutSettings().focusWhere).toBe("");
|
||||
expect(normalizeShortcutSettings({ executeSql: "Mod+Enter" }).focusWhere).toBe("");
|
||||
expect(normalizeShortcutSettings({ focusWhere: "" }).focusWhere).toBe("");
|
||||
const shortcuts = normalizeShortcutSettings({ focusWhere: "Mod+D" });
|
||||
expect(shortcuts.focusWhere).toBe("Mod+D");
|
||||
expect(findShortcutConflict("focusWhere", shortcuts.focusWhere, shortcuts)).toBe("copyCurrentRow");
|
||||
});
|
||||
|
||||
it("registers go to column as an unassigned grid shortcut", () => {
|
||||
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "goToColumn");
|
||||
|
||||
|
||||
Reference in new issue
Block a user