fix(desktop): stop the quit shortcut from reaching input handlers

This commit is contained in:
Saoud Rizwan
2026-10-22 23:55:35 +00:00
parent beb8aec37b
commit 79b8bcabc9
2 changed files with 18 additions and 0 deletions
@@ -152,6 +152,23 @@ describe("QuitHoldHandler", () => {
expect(vi.getTimerCount()).toBe(0);
});
it("keeps the quit shortcut from reaching input handlers", () => {
const input = document.createElement("textarea");
container.appendChild(input);
const onInputKeyDown = vi.fn();
input.addEventListener("keydown", onInputKeyDown);
act(() => {
input.dispatchEvent(
new KeyboardEvent("keydown", {
bubbles: true,
key: "q",
metaKey: true,
}),
);
});
expect(onInputKeyDown).not.toHaveBeenCalled();
});
it("does not quit when repeats stop before the hold threshold", () => {
press();
advance(500);
@@ -109,6 +109,7 @@ export function QuitHoldHandler({
if (areShortcutsSuspended()) return stop();
if (!matchesAccelerator(event, accelerator)) return;
event.preventDefault();
event.stopImmediatePropagation();
if (holdMs === 0) {
if (!event.repeat) quitApp();
return;