From 9ed12fa1d89d6b7f0e04112be5c22e3deff3418e Mon Sep 17 00:00:00 2001 From: SW Date: Thu, 1 Oct 2026 15:21:57 +0200 Subject: [PATCH] fix: close all modals on page load and before form submit --- static/app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/static/app.js b/static/app.js index 58a714b..bffebaf 100644 --- a/static/app.js +++ b/static/app.js @@ -1,6 +1,11 @@ function initApp() { console.log('sub-aligator app.js initialized'); + // Ensure every modal starts closed, even if the browser restored a cached state. + document.querySelectorAll('.modal-overlay').forEach(function (modal) { + modal.style.display = 'none'; + }); + // Open allocation modal document.querySelectorAll('.allocate-btn').forEach(function (btn) { btn.addEventListener('click', function () { @@ -46,6 +51,16 @@ function initApp() { event.stopPropagation(); }); }); + + // Hide the modal right before its form is submitted. + document.querySelectorAll('.modal form').forEach(function (form) { + form.addEventListener('submit', function () { + const overlay = form.closest('.modal-overlay'); + if (overlay) { + overlay.style.display = 'none'; + } + }); + }); } async function openAllocateModal(btn) {