fabrica

hanna/fabrica

feat(web): close clone/branch dropdowns on outside click or Escape

a1ed23e · hanna committed on 2026-07-25

Native <details> menus stay open until re-clicked; close any open clone or
branch dropdown when a click lands outside it, and on Escape. The no-JS
fallback (second-click to close) is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed by hannaSSH key fingerprint: SHA256:4g9cWhkAAw8gwqhJUcVbSnGEvdGwklW+1Aa/fMUu59k
1 files changed · +13 −0UnifiedSplit
assets/fabrica.js +13 −0
@@ -46,6 +46,16 @@
4646 if (picker.form) picker.form.submit();
4747 });
4848
49+ // ---- Dropdowns (details-based popovers) ----
50+ // Native <details> stays open until its summary is clicked again; close any
51+ // open menu when a click lands outside it. Without JS the menus still work,
52+ // they just close on a second summary click.
53+ document.addEventListener("click", function (e) {
54+ document.querySelectorAll("details.clone-menu[open], details.branch-menu[open]").forEach(function (d) {
55+ if (!d.contains(e.target)) d.removeAttribute("open");
56+ });
57+ });
58+
4959 // ---- Clipboard buttons ----
5060 document.addEventListener("click", function (e) {
5161 var btn = e.target.closest("[data-clipboard]");
@@ -81,6 +91,9 @@
8191 }
8292 } else if (e.key === "Escape") {
8393 toggleDrawer(false);
94+ document.querySelectorAll("details.clone-menu[open], details.branch-menu[open]").forEach(function (d) {
95+ d.removeAttribute("open");
96+ });
8497 }
8598 });
8699 })();