Fix: edit button on referenced widgets opened list view instead of edit
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.
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user