From 57fe04ae7bb25f8758a3d1c4c10dce79fe9dfe00 Mon Sep 17 00:00:00 2001 From: Developer Date: Mon, 6 Jul 2026 14:59:24 +0000 Subject: [PATCH] Fix: edit button on referenced widgets opened list view instead of edit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The WidgetConfigDialog useEffect that auto-enters edit mode when editWidgetId is set only searched owned widget instances (from useWidgetInstances). Referenced widgets (from useWidgetReferences) were never found, so startEdit never fired and the dialog fell through to the list view. Now the effect searches both owned instances and referenced widgets, so clicking edit on any widget — owned or referenced — opens the edit form directly. 128 tests pass; 0 lint errors; build clean. --- frontend/src/components/WidgetConfigDialog.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/WidgetConfigDialog.tsx b/frontend/src/components/WidgetConfigDialog.tsx index 04d0d1c..90b8a66 100644 --- a/frontend/src/components/WidgetConfigDialog.tsx +++ b/frontend/src/components/WidgetConfigDialog.tsx @@ -235,13 +235,15 @@ export function WidgetConfigDialog({ // When editWidgetId is set and the dialog opens, auto-enter edit mode for // that widget (instead of showing the list view). useEffect(() => { - if (open && editWidgetId && instances.length > 0) { - const target = instances.find((w) => w.id === editWidgetId); + if (open && editWidgetId) { + // Search both owned widgets and referenced widgets. + const target = instances.find((w) => w.id === editWidgetId) + ?? references.find((r) => r.widget.id === editWidgetId)?.widget; if (target) { startEdit(target); } } - }, [open, editWidgetId, instances]); + }, [open, editWidgetId, instances, references]); function startAddBuiltIn(kind: string) { const binding = BUILTIN_WIDGETS[kind];