From e27aef33ac8b698b620fd975d03bfc66f65ba4bc Mon Sep 17 00:00:00 2001 From: serversdown Date: Wed, 10 Jun 2026 18:34:15 +0000 Subject: [PATCH] fix(slm): guard htmx.trigger so deploy/bench doesn't throw on pages without #slm-list toggleSLMDeployed() and the save-config success path both called htmx.trigger('#slm-list', 'load') guarded only by `typeof htmx !== 'undefined'`. No page actually has a #slm-list element, so htmx resolved the selector to null and called null.dispatchEvent(...) -> "can't access property dispatchEvent, e is null". The deploy POST had already succeeded and the green success message had already rendered, so the user saw both "Unit marked as deployed." and a red error. Guard the trigger on the element existing so it's a harmless no-op. Co-Authored-By: Claude Opus 4.8 --- templates/partials/slm_settings_modal.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/partials/slm_settings_modal.html b/templates/partials/slm_settings_modal.html index 02e9ac6..0b89025 100644 --- a/templates/partials/slm_settings_modal.html +++ b/templates/partials/slm_settings_modal.html @@ -528,7 +528,7 @@ async function saveSLMSettings(event) { if (typeof checkFTPStatus === 'function') { checkFTPStatus(unitId); } - if (typeof htmx !== 'undefined') { + if (typeof htmx !== 'undefined' && document.getElementById('slm-list')) { htmx.trigger('#slm-list', 'load'); } }, 1500); @@ -604,8 +604,10 @@ async function toggleSLMDeployed() { successDiv.classList.remove('hidden'); setTimeout(() => successDiv.classList.add('hidden'), 3000); - // Refresh any SLM list on the page - if (typeof htmx !== 'undefined') { + // Refresh any SLM list on the page (only if one is actually present — + // the detail/dashboard pages have no #slm-list, and htmx.trigger on a + // null target throws "can't access property dispatchEvent, e is null"). + if (typeof htmx !== 'undefined' && document.getElementById('slm-list')) { htmx.trigger('#slm-list', 'load'); } } catch (error) {