TypeScript
fix(desktop): restore second-press quit fallback (#9485)
maria678f23a69943
diff --git a/apps/desktop/src/window/QuitHold.test.ts b/apps/desktop/src/window/QuitHold.test.tsindex fb12be2162c..c4bf2f34b0a 100644--- a/apps/desktop/src/window/QuitHold.test.ts+++ b/apps/desktop/src/window/QuitHold.test.ts@@ -368,14 +368,14 @@ describe("makeQuitShortcutHandler", () => {expect(harness.notifications).toEqual([DOUBLE_CLICK_DOWN, UP, DOUBLE_CLICK_DOWN]);});- it("does not treat two quick presses as a quit in hold mode", async () => {+ it("quits on a quick second press in hold mode", async () => {const harness = makeHarness();await harness.send(makeInput({}));await harness.send(makeInput({ type: "keyUp" }));vi.advanceTimersByTime(QUIT_DOUBLE_PRESS_MS - 100);await harness.send(makeInput({}));- expect(harness.quit).not.toHaveBeenCalled();- expect(harness.notifications).toEqual([HOLD_DOWN, UP, HOLD_DOWN]);+ expect(harness.quit).toHaveBeenCalledTimes(1);+ expect(harness.notifications).toEqual([HOLD_DOWN, UP]);});it("cancels the hold when another key interrupts it", async () => {diff --git a/apps/desktop/src/window/QuitHold.ts b/apps/desktop/src/window/QuitHold.tsindex 7088f4f28ce..4095e3d4354 100644--- a/apps/desktop/src/window/QuitHold.ts+++ b/apps/desktop/src/window/QuitHold.ts@@ -181,11 +181,9 @@ export function makeQuitShortcutHandler(quitNow();return;}- if (- resolvedMode === "double-click" &&- previousPressAt !== 0 &&- now - previousPressAt <= QUIT_DOUBLE_PRESS_MS- ) {+ // Keep a second press as an escape hatch when macOS misses the events+ // that would complete a hold.+ if (previousPressAt !== 0 && now - previousPressAt <= QUIT_DOUBLE_PRESS_MS) {quitNow();return;}