diff --git a/TaxBaik.Web/wwwroot/js/admin-session.js b/TaxBaik.Web/wwwroot/js/admin-session.js index 5373775..34a3cee 100644 --- a/TaxBaik.Web/wwwroot/js/admin-session.js +++ b/TaxBaik.Web/wwwroot/js/admin-session.js @@ -17,7 +17,20 @@ window.taxbaikAdminSession = { const overlay = document.getElementById('blazor-loading'); if (!overlay) return; - // Start observer FIRST so it catches the mutation that brings new content in. + // Show overlay immediately + overlay.classList.add('show'); + + // Check if page is already ready (cached state on fast nav) + const pageReady = + document.querySelector('.admin-page-hero') !== null || + document.querySelector('.admin-login-page') !== null; + if (pageReady) { + // Page already rendered, hide immediately + window.taxbaikAdminSession.hideLoading(); + return; + } + + // Start observer to catch future mutations if (window._taxbaikLoadingObserver) { window._taxbaikLoadingObserver.disconnect(); } @@ -34,9 +47,6 @@ window.taxbaikAdminSession = { subtree: true }); - // Show overlay after observer is active. - overlay.classList.add('show'); - // Safety fallback: hide after 3 seconds regardless. if (window._taxbaikLoadingTimeout) { clearTimeout(window._taxbaikLoadingTimeout);