From cac5e3c4ec338343aa68e66250cf1c11660249bc Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Tue, 18 Aug 2026 12:50:10 +0530 Subject: [PATCH] Clear OPD modal backdrop during navigation --- app/Views/abdm/opd_queue.php | 54 +++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/app/Views/abdm/opd_queue.php b/app/Views/abdm/opd_queue.php index 9a2f837..a1025e1 100644 --- a/app/Views/abdm/opd_queue.php +++ b/app/Views/abdm/opd_queue.php @@ -226,6 +226,37 @@ const el = document.getElementById('abdmOpdRegisterModal'); return !!(el && el.classList.contains('show')); } + function cleanupBootstrapModalState() { + document.querySelectorAll('.modal.show').forEach(modalEl => { + const instance = bootstrap.Modal.getInstance(modalEl); + if (instance) instance.hide(); + modalEl.classList.remove('show'); + modalEl.setAttribute('aria-hidden', 'true'); + modalEl.removeAttribute('aria-modal'); + modalEl.removeAttribute('role'); + modalEl.style.display = 'none'; + }); + document.querySelectorAll('.modal-backdrop').forEach(backdrop => backdrop.remove()); + document.body.classList.remove('modal-open'); + document.body.style.removeProperty('padding-right'); + } + function closeProcessModal(onClosed) { + const modalEl = document.getElementById('abdmQueueModalProcess'); + if (!modalEl || !modalEl.classList.contains('show')) { + if (typeof onClosed === 'function') onClosed(); + return; + } + const cleanup = function () { + cleanupBootstrapModalState(); + }; + const finish = function () { + modalEl.removeEventListener('hidden.bs.modal', finish); + cleanup(); + if (typeof onClosed === 'function') onClosed(); + }; + modalEl.addEventListener('hidden.bs.modal', finish); + bootstrap.Modal.getOrCreateInstance(modalEl).hide(); + } function executeInjectedScripts(containerId) { const container = document.getElementById(containerId); if (!container) { @@ -754,8 +785,8 @@ ${r.saved_data ? `
Saved: ${esc([r.saved_data.relation, r.saved_data.email, r.saved_data.address].filter(Boolean).join(' | ') || 'Basic fields')}
` : ''} - - + + `; loadQueue(); return; @@ -814,10 +845,25 @@ document.getElementById('queueStatus').addEventListener('change', loadQueue); window.abdmQOpenOpdInModal = function (url) { - openOpdRegistrationModal(url); + closeProcessModal(function () { + openOpdRegistrationModal(url); + }); }; - window.pageCleanup = function () { clearTimeout(autoTimer); }; + window.abdmQOpenPageAfterProcess = function (url, title) { + closeProcessModal(function () { + if (typeof window.load_form === 'function') { + window.load_form(url, title || ''); + } else { + window.location.href = url; + } + }); + }; + + window.pageCleanup = function () { + clearTimeout(autoTimer); + cleanupBootstrapModalState(); + }; loadQueue(); })();