From 50f8e0a938f2de6cca412a55df3815f9ef5bf1a1 Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 16 Jul 2026 09:29:34 -0400 Subject: [PATCH] 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 --- app/templates/base.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/templates/base.html b/app/templates/base.html index 0b402b7..9305259 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -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(); }