mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-24 14:16:06 +00:00
Always use hash for dashboard tabs
Previously the dashboard used a clean root URL for the 'apps' tab and hashes for other tabs. This change makes tab links and history entries consistently use a hash (e.g. #apps, #home) by always generating href as `#<id>` and pushing `#<section>` to history. Simplifies URL handling and ensures the Apps tab also reflects its hash in the address bar.
This commit is contained in:
@@ -104,8 +104,7 @@ async function UIDashboard (options) {
|
||||
continue;
|
||||
}
|
||||
const isActive = tab.id === initialTabId ? ' active' : '';
|
||||
const tabHash = tab.id === 'apps' ? '' : `#${tab.id}`;
|
||||
const tabHref = tabHash || window.location.pathname;
|
||||
const tabHref = `#${tab.id}`;
|
||||
h += `<a class="dashboard-sidebar-item allow-native-ctxmenu${isActive}" href="${tabHref}" data-section="${tab.id}" data-tooltip="${html_encode(tab.label)}">`;
|
||||
h += tab.icon;
|
||||
h += tab.label;
|
||||
@@ -321,10 +320,9 @@ async function UIDashboard (options) {
|
||||
document.querySelector('.dashboard-content').setAttribute('class', 'dashboard-content');
|
||||
document.querySelector('.dashboard-content').classList.add(section);
|
||||
|
||||
// Update hash to reflect current tab. Apps is the default tab, so it
|
||||
// uses the clean root URL; every other tab (including home) uses #tab.
|
||||
const newHash = section === 'apps' ? '' : section;
|
||||
history.pushState(null, '', newHash ? `#${newHash}` : window.location.pathname);
|
||||
// Reflect the current tab in the hash. Root (no hash) defaults to Apps,
|
||||
// but selecting any tab — including Apps — shows its #tab.
|
||||
history.pushState(null, '', `#${section}`);
|
||||
|
||||
// Scroll content area to top
|
||||
$el_window.find('.dashboard-content').scrollTop(0);
|
||||
|
||||
Reference in New Issue
Block a user