From 087ee44f1224bd6961bb95167243e7e22b16c8b9 Mon Sep 17 00:00:00 2001 From: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> Date: Thu, 16 Jul 2026 01:14:52 +0300 Subject: [PATCH] ignore backdrop click within 300ms of showing a modal a click that focuses the window lands on the modal backdrop too, so the update-available prompt after an unattended auto-check could get dismissed by the very click that brought the window to front, before it was ever seen --- src/main.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index e65f845..a202097 100644 --- a/src/main.ts +++ b/src/main.ts @@ -674,6 +674,7 @@ function askModal(msg: string, aLabel: string, bLabel: string): Promise<"a" | "b b.textContent = bLabel; a.classList.add("primary"); modal.classList.remove("hidden"); + const shownAt = Date.now(); const done = (res: "a" | "b" | null) => { modal.classList.add("hidden"); a.onclick = b.onclick = modal.onclick = null; @@ -682,7 +683,10 @@ function askModal(msg: string, aLabel: string, bLabel: string): Promise<"a" | "b a.onclick = () => done("a"); b.onclick = () => done("b"); modal.onclick = (e) => { - if (e.target === modal) done(null); + // a click that focuses the window (e.g. after an unattended auto-check + // shows this modal) lands on the backdrop too — ignore it right after + // showing so it can't dismiss a prompt the user hasn't actually seen yet + if (e.target === modal && Date.now() - shownAt > 300) done(null); }; }); }