From 2af70508009a8957cef4215a9dedbac6a1c0a1b4 Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Sun, 28 Jun 2026 15:35:06 +0900 Subject: [PATCH] fix: check cached page state in showLoading() before starting MutationObserver - Page may be already rendered when showLoading() is called (fast nav, cached state) - Check .admin-page-hero / .admin-login-page immediately and hide if present - Prevents stuck loading overlay on rapid navigation between pages Co-Authored-By: Claude Haiku 4.5 --- TaxBaik.Web/wwwroot/js/admin-session.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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);