╭ changed ──────────╮ │src/embed/script.js│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │223 wasmInstance.exports._tick(minRows(), maxCols()); │ │224 }); │ │225 │ │226 + // submit on mousedown rather than waiting for click: the focusin this │ │227 + // same mousedown fires ticks the wasm, and a resulting overlay rebuild │ │228 + // would detach the button before its click could land. the form is │ │229 + // guaranteed live at mousedown time. │ │230 + document.addEventListener("mousedown", (event) => { │ │231 + if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; │ │232 + const btn = event.target.closest ? event.target.closest("button[type=submit][data-focus-id]") : null;│ │233 + if (!btn || !btn.form) return; │ │234 + // empty-action forms are handled by their onsubmit on the click path │ │235 + if (!btn.form.getAttribute("action")) return; │ │236 + // if the button survives to receive the click, don't submit twice │ │237 + btn.addEventListener("click", (e) => e.preventDefault(), { once: true }); │ │238 + btn.form.requestSubmit(btn); │ │239 + }); │ │240 + │ │241 // listeners on document (not #grid) since the form lives outside #grid; │ │242 // input/focus events from form elements still bubble up to document. │ │243 document.addEventListener("input", (event) => { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯