fix: arbre collapse après drag-drop (expanded persistant via localStorage)
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

Avant: tout window.location.reload() réinitialisait expanded={},
causant le collapse de tous les dossiers après un drop.

Fix:
- expanded initialisé depuis localStorage('fd_ws_expanded')
- _saveExpandedState() sauve avant toute navigation/reload
- _reloadAfterAction() = save + reload
- toggleExpand, navigateToFolder, expandAll sauvent l'état
- Tous les reload (create, rename, delete, move, upload) passent par _reloadAfterAction()
This commit is contained in:
2026-07-11 13:42:02 -04:00
parent 08d2bac793
commit a8f9832535
+20 -6
View File
@@ -300,7 +300,10 @@ document.addEventListener('alpine:init', function() {
newName:'',
parentFolder:null,
target:null,
expanded: {},
expanded: (function() {
try { return JSON.parse(localStorage.getItem('fd_ws_expanded') || '{}'); }
catch(e) { return {}; }
})(),
currentFolder: {{ current_folder_id }},
searchQuery: '',
@@ -429,6 +432,7 @@ document.addEventListener('alpine:init', function() {
toggleExpand(id, btn) {
this.expanded[id] = !(this.expanded[id] || false);
this.expanded = Object.assign({}, this.expanded);
this._saveExpandedState();
// For renderChildren static HTML: toggle chevron + sibling <ul>
if (btn) {
btn.classList.toggle('open', this.expanded[id]);
@@ -447,9 +451,19 @@ document.addEventListener('alpine:init', function() {
},
navigateToFolder(id) {
this._saveExpandedState();
window.location = '/local-workspace?folder=' + id;
},
_saveExpandedState() {
try { localStorage.setItem('fd_ws_expanded', JSON.stringify(this.expanded)); }
catch(e) {}
},
_reloadAfterAction() {
this._saveExpandedState();
this._reloadAfterAction();
},
// ── Expand / Collapse all ──
expandAll() {
var self = this;
@@ -597,7 +611,7 @@ document.addEventListener('alpine:init', function() {
this.showCreate = false;
this.parentFolder = null;
this.newName = '';
window.location.reload();
this._reloadAfterAction();
}
},
@@ -622,7 +636,7 @@ document.addEventListener('alpine:init', function() {
headers:{'Content-Type':'application/json'},
body:JSON.stringify({name:n})
});
if (r.ok) { window.location.reload(); }
if (r.ok) { this._reloadAfterAction(); }
},
startDelete(node) {
@@ -633,7 +647,7 @@ document.addEventListener('alpine:init', function() {
async doDelete() {
if (!this.target) return;
var r = await fetch('/api/local-workspace/items/'+this.target.db_id, { method:'DELETE' });
if (r.ok) { window.location.reload(); }
if (r.ok) { this._reloadAfterAction(); }
},
// ── Drag & Drop ──
@@ -829,7 +843,7 @@ document.addEventListener('alpine:init', function() {
body: JSON.stringify(body)
});
if (r.ok) {
window.location.reload();
this._reloadAfterAction();
} else {
alert('Move failed');
}
@@ -857,7 +871,7 @@ document.addEventListener('alpine:init', function() {
var items = d.items || [];
setTimeout(function() {
self.uploading = false;
window.location.reload();
this._reloadAfterAction();
}, 800);
} else {
this.uploadStatus = '✗ ' + (d.error || 'Upload failed');