feat(shortcuts): suppress Shift+Esc browser task manager
This commit is contained in:
1 parent
b498b1e63a
commit
37d5ea0bd4
4 files changed
+49
-1
No files matched your search
@@ -106,6 +106,7 @@ import { activeDesktopAiRuns, blockingDesktopAiRunsForQuit } from "@/lib/ai/desk
|
||||
|
||||
import {
|
||||
isBrowserReloadShortcut,
|
||||
isBrowserTaskManagerShortcut,
|
||||
isCloseOtherTabsShortcut,
|
||||
isCloseTabShortcut,
|
||||
isExecuteSqlInNewResultTabShortcut,
|
||||
@@ -3707,6 +3708,11 @@ const tabSwitcherKeyboard = createTabSwitcherKeyboardController({
|
||||
});
|
||||
|
||||
function handleNativeSelectAll(e: KeyboardEvent) {
|
||||
if (isBrowserTaskManagerShortcut(e)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
if (shouldBlockAppNativeSelectAll(e)) e.preventDefault();
|
||||
}
|
||||
|
||||
@@ -4000,6 +4006,11 @@ async function handleKeydown(e: KeyboardEvent) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isBrowserTaskManagerShortcut(e)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
if (isDesktop && isBrowserReloadShortcut(e)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@@ -4174,6 +4185,7 @@ watch(appReady, (ready) => void syncConnectionLivenessSubscription(ready), { imm
|
||||
onMounted(async () => {
|
||||
clearStartupPreloadRetry();
|
||||
markStartupPhase("app-mounted");
|
||||
window.addEventListener("keydown", handleNativeSelectAll, true);
|
||||
console.log("[STARTUP] onMounted begin");
|
||||
const mountStart = performance.now();
|
||||
if (isDetachedWindowContext) {
|
||||
@@ -4195,7 +4207,6 @@ onMounted(async () => {
|
||||
});
|
||||
applyTheme();
|
||||
void applyUiScale(settingsStore.editorSettings.uiScale);
|
||||
window.addEventListener("keydown", handleNativeSelectAll, true);
|
||||
window.addEventListener("keydown", handleGlobalSearchKeydownCapture, true);
|
||||
window.addEventListener("keydown", handleTabSwitcherKeydownCapture, true);
|
||||
window.addEventListener("keydown", handleAuxiliarySearchKeydownCapture, true);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
eventToModifierOnlyShortcut,
|
||||
eventToShortcut,
|
||||
isBrowserTaskManagerShortcut,
|
||||
isConvertNamingStyleShortcut,
|
||||
isEditTableStructureShortcut,
|
||||
isExecuteSqlInNewResultTabShortcut,
|
||||
@@ -264,3 +265,19 @@ describe("tabSwitcherDirectionFromShortcut", () => {
|
||||
expect(tabSwitcherDirectionFromShortcut({ key: "Tab", ctrlKey: true }, { tabSwitcher: "Shift+Ctrl+Tab" })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("isBrowserTaskManagerShortcut", () => {
|
||||
it("matches Shift+Escape combinations and rejects regular Escape or extra modifiers", () => {
|
||||
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true })).toBe(true);
|
||||
expect(isBrowserTaskManagerShortcut({ key: "Esc", shiftKey: true })).toBe(true);
|
||||
expect(isBrowserTaskManagerShortcut({ code: "Escape", shiftKey: true, key: "Unidentified" })).toBe(true);
|
||||
|
||||
expect(isBrowserTaskManagerShortcut({ key: "Escape" })).toBe(false);
|
||||
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: false })).toBe(false);
|
||||
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true, ctrlKey: true })).toBe(false);
|
||||
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true, metaKey: true })).toBe(false);
|
||||
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true, altKey: true })).toBe(false);
|
||||
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true, isComposing: true })).toBe(false);
|
||||
expect(isBrowserTaskManagerShortcut({ key: "x", shiftKey: true })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -383,3 +383,9 @@ export function isBrowserReloadShortcut(event: ShortcutLikeEvent): boolean {
|
||||
if (key === "F5") return true;
|
||||
return key === "r" && (!!event.metaKey || !!event.ctrlKey);
|
||||
}
|
||||
|
||||
export function isBrowserTaskManagerShortcut(event: ShortcutLikeEvent): boolean {
|
||||
if (event.isComposing || event.altKey || event.ctrlKey || event.metaKey) return false;
|
||||
if (!event.shiftKey) return false;
|
||||
return event.key === "Escape" || event.key === "Esc" || event.code === "Escape";
|
||||
}
|
||||
Reference in new issue
Block a user