From 75df623982d63f815afd08f38b143320263a65e7 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 28 Mar 2026 21:20:58 -0400 Subject: [PATCH] Fix collections page Alpine errors and modal container issues Fixed multiple issues preventing the collections page and modals from working correctly: 1. Alpine Expression Error on page load: - Added missing semicolon between function calls in x-init directive - Added missing parentheses to initializeCollectionWebSocket() call - Collections page now loads without JavaScript errors 2. Modal container removal bug: - Fixed closeCollectionModal() removing #modal-container parent element - Changed from modal.parentElement.remove() to modal.remove() - Modal can now be opened and closed multiple times without errors - Fixes htmx:targetError when trying to open modal after first close 3. Emoji grid display: - Modal now properly preserves container across open/close cycles - setupHTMXModalInit() can successfully repopulate icon grid - Emoji picker displays correctly on all modal opens Technical details: - templates/collections.templ: Fixed x-init syntax errors - web/src/collections.ts: Fixed modal close logic to preserve container - Modal container persists across HTMX swaps, allowing repeated use --- templates/collections.templ | 4 ++-- templates/collections_templ.go | 4 ++-- web/src/collections.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/collections.templ b/templates/collections.templ index e78b7c4..5f3854a 100644 --- a/templates/collections.templ +++ b/templates/collections.templ @@ -12,7 +12,7 @@ templ Collection(user User, collections []CollectionData, errorMessage string) { - + @Header(user, "/collections") @@ -110,7 +110,7 @@ templ CollectionDetail(user User, collection CollectionData, books []handlers.Bo - + @Header(user, "/collections")
diff --git a/templates/collections_templ.go b/templates/collections_templ.go index 5e0d8f8..8fca02c 100644 --- a/templates/collections_templ.go +++ b/templates/collections_templ.go @@ -31,7 +31,7 @@ func Collection(user User, collections []CollectionData, errorMessage string) te templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Collections - Bookhoard") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Collections - Bookhoard") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -196,7 +196,7 @@ func CollectionDetail(user User, collection CollectionData, books []handlers.Boo if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " - Bookhoard") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " - Bookhoard") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/web/src/collections.ts b/web/src/collections.ts index 4ec8e7d..a72c897 100644 --- a/web/src/collections.ts +++ b/web/src/collections.ts @@ -302,8 +302,8 @@ function selectColor(color: string): void { // Close modal (removes from DOM) function closeCollectionModal(): void { const modal = document.querySelector(".fixed.inset-0"); - if (modal && modal.parentElement) { - modal.parentElement.remove(); + if (modal) { + modal.remove(); } }