fix(admin): guard htmx:confirm handler against empty question

The handler called evt.preventDefault() unconditionally, so auto-poll
requests (hx-trigger="every 5s", no hx-confirm) caused an empty dialog
to pop up every 5 seconds. Add an early return when evt.detail.question
is falsy so only actual hx-confirm interactions are intercepted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-03-01 22:39:38 +01:00
parent f9e22a72dd
commit c1cf472caf

View File

@@ -247,6 +247,7 @@ function confirmAction(message, form) {
// Intercept hx-confirm to use the styled dialog instead of window.confirm()
document.body.addEventListener('htmx:confirm', function(evt) {
if (!evt.detail.question) return; // no hx-confirm on this element, let HTMX proceed
var dialog = document.getElementById('confirm-dialog');
if (!dialog) return; // fallback: let HTMX use native confirm
evt.preventDefault();