From bb3bb805670af172529bba8e037775806d5eab0a Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Wed, 24 Jun 2026 11:12:56 +0200 Subject: [PATCH] Fix accordion re-init after HTMX outerHTML swap on repertoire page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The htmx:afterSwap handler was calling initAccordions(e.detail.target) but after an outerHTML swap, e.detail.target references the old detached DOM element, not the new live element. This meant accordion click handlers were never attached to the new filter column toggles after applying or removing a filter — breaking all subsequent interaction. Fix: query the live DOM with document.querySelector() instead. --- app/templates/public/repertoire.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/templates/public/repertoire.php b/app/templates/public/repertoire.php index 41286e0..afd35a2 100644 --- a/app/templates/public/repertoire.php +++ b/app/templates/public/repertoire.php @@ -96,10 +96,12 @@ // Initial bind initAccordions(document); - // Re-bind after HTMX swaps + // Re-bind after HTMX swaps. + // Must query the live DOM — e.detail.target is the *old* detached element after outerHTML swaps. document.body.addEventListener('htmx:afterSwap', function (e) { if (e.detail.target && e.detail.target.matches && e.detail.target.matches(INDEX_SEL)) { - initAccordions(e.detail.target); + var liveIndex = document.querySelector(INDEX_SEL); + if (liveIndex) initAccordions(liveIndex); } });