mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-25 23:46:51 +00:00
fix: refresh Dashboard tabs when navigating via browser back/forward
The sidebar-click and initial-route handlers both call the target tab's onActivate (its refresh hook), but handleRouteChange — wired to hashchange and popstate — only swapped the active classes. Since tab switches use history.pushState (which doesn't fire popstate/hashchange), the only way to reach handleRouteChange is browser back/forward, and doing so left tabs like Home/Apps showing stale data. Look up the tab by id and call onActivate after switching, matching the sidebar-click path.
This commit is contained in:
@@ -396,6 +396,14 @@ async function UIDashboard (options) {
|
||||
document.querySelector('.dashboard-content').classList.add(tab);
|
||||
}
|
||||
|
||||
// Refresh the tab we just switched to, mirroring the sidebar-click
|
||||
// handler — otherwise reaching a tab via browser back/forward leaves it
|
||||
// showing stale data because its onActivate never runs.
|
||||
const activeTab = tabs.find(t => t !== '-' && t.id === tab);
|
||||
if ( activeTab?.onActivate ) {
|
||||
activeTab.onActivate($el_window);
|
||||
}
|
||||
|
||||
// Scroll content area to top
|
||||
$el_window.find('.dashboard-content').scrollTop(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user