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 <noreply@anthropic.com>
This commit is contained in:
Nate HerkandClaude Opus 5.5 committed 2026-10-21 21:00:36 -05:00
1 parent e5b1267717
commit e40f40652d
1 file changed
+11
+11
View File
@@ -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)));