fix(collections): Close/Cancel removed the hidden confirm dialog, not the modal

closeCollectionModal picked document.querySelector(".fixed.inset-0") —
the FIRST overlay in DOM order, which is the sitewide #confirm-modal
that the header renders (hidden, display:none, but present). The real
create/edit modal stayed open: every Close and Cancel click on the
collection modals did nothing. Caught by the knob-matrix spec — the
pencil-glyph case clicked Close and the Edit modal persisted.

The buttons now pass $el and the overlay OWNING the button is closed
(closest(".fixed.inset-0")), falling back to #modal-container's child
for non-Alpine callers. Both the collection create/edit modal and the
restore-system modal take the argument.
This commit is contained in:
John O'Keefe committed 2026-10-31 15:40:21 -04:00
1 parent 21142cae5f
commit 79b47c9680
6 files changed
+20 -13

No files matched your search

+9 -2
View File
@@ -97,8 +97,15 @@ function selectColor(color: string): void {
}
}
function closeCollectionModal(): void {
const modal = document.querySelector(".fixed.inset-0");
function closeCollectionModal(from?: HTMLElement): void {
// The overlay OWNING the caller's button — never `.fixed.inset-0`:
// that bare selector matched the SITEWIDE confirm modal first (it
// renders in the header, before any modal container), so Close
// removed a hidden dialog and left the real modal open — Close and
// Cancel did nothing (knob-matrix spec, 2026-10-31).
const modal =
from?.closest(".fixed.inset-0") ??
document.querySelector("#modal-container > .fixed.inset-0");
if (modal) {
modal.remove();
}