fix: sidebar drag-drop uses dynamic refresh instead of full page reload
- Sidebar 'drop' handler now calls refreshSidebarTree() + dispatches 'flowdeck:workspace-changed' instead of window.location.reload() - Global refreshSidebarFromEvent() now targets .app-layout[x-data] first to avoid picking up the wrong Alpine component when multiple x-data elements exist on the page
This commit is contained in:
@@ -987,7 +987,11 @@
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
|
||||
body: JSON.stringify({ parent_id: parentId })
|
||||
})
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); window.location.reload(); })
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); })
|
||||
.then(() => {
|
||||
this.refreshSidebarTree();
|
||||
document.dispatchEvent(new CustomEvent('flowdeck:workspace-changed'));
|
||||
})
|
||||
.catch(err => { this.toast('Move failed: ' + err.message, 'error'); });
|
||||
},
|
||||
|
||||
@@ -1156,7 +1160,9 @@
|
||||
|
||||
// -- Global sidebar refresh handler (called after any CRUD) --
|
||||
function refreshSidebarFromEvent() {
|
||||
var appEl = document.querySelector('[x-data]');
|
||||
// Try appState first (outer x-data), then any x-data with refreshSidebarTree
|
||||
var appEl = document.querySelector('.app-layout[x-data]');
|
||||
if (!appEl) appEl = document.querySelector('[x-data]');
|
||||
var data = appEl && appEl.__x ? appEl.__x.$data : null;
|
||||
if (data && data.refreshSidebarTree) data.refreshSidebarTree();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user