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 @@
46 if (picker.form) picker.form.submit();46 if (picker.form) picker.form.submit();
47 });47 });
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
49 // ---- Clipboard buttons ----59 // ---- Clipboard buttons ----
50 document.addEventListener("click", function (e) {60 document.addEventListener("click", function (e) {
51 var btn = e.target.closest("[data-clipboard]");61 var btn = e.target.closest("[data-clipboard]");
@@ -81,6 +91,9 @@
81 }91 }
82 } else if (e.key === "Escape") {92 } else if (e.key === "Escape") {
83 toggleDrawer(false);93 toggleDrawer(false);
94 document.querySelectorAll("details.clone-menu[open], details.branch-menu[open]").forEach(function (d) {
95 d.removeAttribute("open");
96 });
84 }97 }
85 });98 });
86})();99})();