From e40f40652d5690c4d9f928c4794c673a99f2cd0e Mon Sep 17 00:00:00 2001 From: Nate Herk <253835467+nateherkai@users.noreply.github.com> Date: Wed, 21 Oct 2026 21:00:36 -0500 Subject: [PATCH] Close cards and dialogs by clicking outside them Clicking the dimmed backdrop around an advisor's card, the guide, or past sessions now closes it, so you no longer have to scroll down to Close. Escape still works. A text selection dragged out of the box does not close it. Co-Authored-By: Claude Opus 5.5 --- app/public/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/public/app.js b/app/public/app.js index dbd588d..5a32d95 100644 --- a/app/public/app.js +++ b/app/public/app.js @@ -267,6 +267,17 @@ function bindUI() { $("#newBtn").addEventListener("click", reset); $("#verdictSheet").addEventListener("click", (e) => { if (e.target.id === "verdictSheet" || e.target.closest("[data-close]")) $("#verdictSheet").hidden = true; }); document.addEventListener("keydown", (e) => { if (e.key === "Escape") $("#verdictSheet").hidden = true; }); + // Clicking the dimmed backdrop around a card, the guide, or past sessions closes it (Escape already does). + // Both press and release must land outside the box, so a text selection dragged out of it never closes it. + $$("dialog.card-dialog").forEach((d) => { + const outside = (e) => { + const r = d.getBoundingClientRect(); + return e.target === d && (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom); + }; + let pressedOutside = false; + d.addEventListener("pointerdown", (e) => { pressedOutside = outside(e); }); + d.addEventListener("click", (e) => { if (pressedOutside && outside(e)) d.close(); pressedOutside = false; }); + }); $$(".speed button").forEach((b) => b.addEventListener("click", () => { player.speed = Number(b.dataset.speed); $$(".speed button").forEach((x) => x.setAttribute("aria-pressed", String(x === b)));