From ea2463fe445b43ca9ce5078fc535a3638426e3fb Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 21 Mar 2026 01:24:21 -0400 Subject: [PATCH] fix(frontend): remove jarring forced reload on dashboard navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unnecessary full page reload that occurred on dashboard load when localStorage library preference didn't match URL parameter. Changes (web/src/dashboard.ts): 1. Remove forced reload logic (lines 514-520, deleted): - Deleted: window.location.href redirect on library mismatch - Removed: localStorage.getItem("selectedLibrary") check - Removed: URL parameter comparison logic 2. Fix localStorage key inconsistency (line 158): - Changed: "selectedLibraryId" → "selectedLibrary" - Now matches: switchLibrary() function (line 230) - Now matches: storage.ts utility (getSelectedLibrary/setSelectedLibrary) - Ensures consistency across entire application User Experience Impact: Before: - Dashboard loads → Checks localStorage vs URL → Forces reload if mismatch ❌ - User switches library → switchLibrary() runs smoothly → But next interaction triggers reload ❌ - Jarring full page reload disrupts UX ❌ After: - Dashboard loads → SSR provides fresh data (no reload) ✅ - User switches library → switchLibrary() fetches fresh data with smooth fade animation ✅ - No forced reloads → Smooth, seamless navigation ✅ Technical Details: The removed code was attempting to restore the user's last-selected library when returning to the dashboard. However, this was redundant because: 1. SSR already provides fresh dashboard data on navigation 2. switchLibrary() function already fetches fresh data via API 3. Library select has change event listener that calls switchLibrary() 4. Forced reload happened BEFORE smooth switching could work The reload logic was added to preserve library selection across sessions, but it caused more UX problems than it solved. Users now get smooth navigation while still maintaining library selection via the dropdown. Browser Testing: - Navigate to /dashboard → Smooth load - Switch library dropdown → Smooth fade transition - Navigate away and back → No forced reload - No console errors Related: Dashboard navigation smoothness User Impact: Eliminates jarring full page reloads --- web/src/dashboard.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/web/src/dashboard.ts b/web/src/dashboard.ts index 7563849..f2ba4b0 100644 --- a/web/src/dashboard.ts +++ b/web/src/dashboard.ts @@ -155,7 +155,7 @@ async function saveDashboardSettings(): Promise { if (sectionResponse.ok) { const data = await sectionResponse.json(); renderDashboardCollections(data.sections); - localStorage.setItem("selectedLibraryId", libraryId); + localStorage.setItem("selectedLibrary", libraryId); } else { showToast("Failed to refresh sections", "error"); } @@ -511,13 +511,6 @@ function initDashboard() { } }); } - const savedLibrary = localStorage.getItem("selectedLibrary"); - const currentLibrary = new URLSearchParams(window.location.search).get( - "library_id", - ); - if (savedLibrary && savedLibrary !== currentLibrary) { - window.location.href = `/dashboard?library_id=${savedLibrary}`; - } }); }