Modals: emit lt:modalclose so openers can react to any dismissal
Lint / JS (eslint) (push) Successful in 8s

A modal can be dismissed four ways: the ✕ button, a Cancel button, a backdrop
click, or Escape. The last two are handled globally in base.js, so code that
wires only the buttons never learns the modal went away — leaving optimistic UI
in place, and leaving dynamically-inserted overlays in the DOM (where the next
open inserts a duplicate id that shadows the live one).

closeModal now dispatches a bubbling lt:modalclose CustomEvent on the overlay.
Existing button handlers keep working; openers that care can listen for it.
This commit is contained in:
2026-08-07 23:05:55 -04:00
parent 0d633bd9de
commit bbec859051
+5
View File
@@ -241,6 +241,11 @@
trigger.focus();
}
}
// Announce the close so whoever opened the modal can undo optimistic UI or
// clean up a dynamically-inserted overlay. A modal can be dismissed four
// ways — the ✕ button, a Cancel button, a backdrop click, and Escape — and
// the last two are handled globally here, so button-only listeners miss them.
el.dispatchEvent(new CustomEvent('lt:modalclose', { bubbles: true }));
}
function closeAllModals() {