fix: sidebar workspace tree collapses on navigation
Root cause: sectionsOpen did not include workspace:true by default, and toggle state was not persisted. On every page navigation, sectionsOpen.workspace defaulted to undefined (falsy), hiding the workspace tree section. Fixes: - sectionsOpen now defaults with workspace:true - sectionsOpen persisted to localStorage on toggle and before navigation - beforeunload handler auto-saves expandedFolders + sectionsOpen (covers <a href> navigation for file clicks too) - navigateToFolder saves both expandedFolders and sectionsOpen
This commit is contained in:
+30
-5
@@ -496,8 +496,19 @@
|
|||||||
favoriteIds: new Set([{% for p in favorite_pages %}'{{ p.id }}'{% if not loop.last %},{% endif %}{% endfor %}]),
|
favoriteIds: new Set([{% for p in favorite_pages %}'{{ p.id }}'{% if not loop.last %},{% endif %}{% endfor %}]),
|
||||||
|
|
||||||
// ── Sections collapsible ──
|
// ── Sections collapsible ──
|
||||||
sectionsOpen: { recents: true, private: true, meetings: true, favorites: true, agents: true, shared: true, apps: true },
|
sectionsOpen: (function() {
|
||||||
toggleSection(key) { this.sectionsOpen[key] = !this.sectionsOpen[key]; this.sectionsOpen = Object.assign({}, this.sectionsOpen); },
|
var def = { recents: true, private: true, meetings: true, favorites: true, agents: true, shared: true, apps: true, workspace: true };
|
||||||
|
try {
|
||||||
|
var saved = JSON.parse(localStorage.getItem('fd_sections') || '{}');
|
||||||
|
return Object.assign(def, saved);
|
||||||
|
} catch(e) { return def; }
|
||||||
|
})(),
|
||||||
|
toggleSection(key) {
|
||||||
|
this.sectionsOpen[key] = !this.sectionsOpen[key];
|
||||||
|
this.sectionsOpen = Object.assign({}, this.sectionsOpen);
|
||||||
|
try { localStorage.setItem('fd_sections', JSON.stringify(this.sectionsOpen)); }
|
||||||
|
catch(e) {}
|
||||||
|
},
|
||||||
toggleWorkspaceMenu() {
|
toggleWorkspaceMenu() {
|
||||||
if (window.innerWidth <= 768) {
|
if (window.innerWidth <= 768) {
|
||||||
this.mobileSidebarOpen = !this.mobileSidebarOpen;
|
this.mobileSidebarOpen = !this.mobileSidebarOpen;
|
||||||
@@ -814,9 +825,11 @@
|
|||||||
catch(e) {}
|
catch(e) {}
|
||||||
},
|
},
|
||||||
navigateToFolder(id) {
|
navigateToFolder(id) {
|
||||||
// Save expansion state before navigating
|
// Save expansion + sections state before navigating
|
||||||
try { localStorage.setItem('fd_expanded_folders', JSON.stringify(this.expandedFolders)); }
|
try {
|
||||||
catch(e) {}
|
localStorage.setItem('fd_expanded_folders', JSON.stringify(this.expandedFolders));
|
||||||
|
localStorage.setItem('fd_sections', JSON.stringify(this.sectionsOpen));
|
||||||
|
} catch(e) {}
|
||||||
window.location = `/local-workspace?folder=${id}`;
|
window.location = `/local-workspace?folder=${id}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -841,6 +854,18 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-save sidebar state before navigation (covers <a href> clicks)
|
||||||
|
window.addEventListener('beforeunload', function() {
|
||||||
|
try {
|
||||||
|
var el = document.querySelector('[x-data]');
|
||||||
|
if (el && el.__x) {
|
||||||
|
var data = el.__x.$data;
|
||||||
|
if (data.expandedFolders) localStorage.setItem('fd_expanded_folders', JSON.stringify(data.expandedFolders));
|
||||||
|
if (data.sectionsOpen) localStorage.setItem('fd_sections', JSON.stringify(data.sectionsOpen));
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<script src="/static/js/app.js" defer></script>
|
<script src="/static/js/app.js" defer></script>
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user