Skip to content

Commit 06b5967

Browse files
Copilothotlong
andcommitted
fix: restore dashboard config save properties, improve stabilization comments
- Restore rowHeight/showDescription/theme in handleDashboardConfigSave (prevents data loss on save) - Simplify dashboardConfig memo dep to [configVersion] alone - Improve comments explaining the configVersion stabilization pattern - Update ROADMAP with widget delete and config stabilization entries Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 2e0c988 commit 06b5967

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

ROADMAP.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,10 @@ ObjectUI is a universal Server-Driven UI (SDUI) engine built on React + Tailwind
384384
- [x] Widget config flattening/unflattening (layout.w ↔ layoutW, layout.h ↔ layoutH)
385385
- [x] Auto-save on config save via `useAdapter().update()`
386386
- [x] Live preview updates via `onFieldChange` callback
387-
- [x] Update 16 integration tests (7 DashboardDesignInteraction + 9 DashboardViewSelection) to verify inline config panel pattern
387+
- [x] Config draft stabilization via `configVersion` counter (matching ViewConfigPanel's `stableActiveView` pattern) — prevents `useConfigDraft` draft reset on live field changes
388+
- [x] Widget delete via `headerExtra` delete button in WidgetConfigPanel header
389+
- [x] `WidgetConfigPanel` — added `headerExtra` prop for custom header actions
390+
- [x] Update 21 integration tests (10 DashboardDesignInteraction + 11 DashboardViewSelection) to verify inline config panel pattern, widget deletion, live preview sync
388391

389392
### P1.11 Console — Schema-Driven View Config Panel Migration
390393

apps/console/src/components/DashboardView.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,14 @@ export function DashboardView({ dataSource }: { dataSource?: any }) {
194194
);
195195

196196
// ---- Dashboard config panel handlers ------------------------------------
197-
// Stabilize config reference: only recompute when panel opens or after save.
198-
// This prevents useConfigDraft from resetting the draft on every parent re-render
199-
// (same pattern as ViewConfigPanel's stableActiveView).
197+
// Stabilize config reference: only recompute after explicit actions (panel
198+
// open, save, widget add). configVersion is incremented on those actions.
199+
// This prevents useConfigDraft from resetting the draft on every live field
200+
// change (same pattern as ViewConfigPanel's stableActiveView).
200201
const dashboardConfig = useMemo(
201202
() => extractDashboardConfig(editSchema || (dashboard as DashboardSchema)),
202203
// eslint-disable-next-line react-hooks/exhaustive-deps
203-
[dashboardName, configVersion],
204+
[configVersion],
204205
);
205206

206207
const handleDashboardConfigSave = useCallback(
@@ -210,8 +211,11 @@ export function DashboardView({ dataSource }: { dataSource?: any }) {
210211
...editSchema,
211212
columns: config.columns,
212213
gap: config.gap,
214+
rowHeight: config.rowHeight,
213215
refreshInterval: Number(config.refreshInterval) || 0,
214216
title: config.title,
217+
showDescription: config.showDescription,
218+
theme: config.theme,
215219
} as DashboardSchema;
216220
setEditSchema(newSchema);
217221
saveSchema(newSchema);
@@ -238,8 +242,10 @@ export function DashboardView({ dataSource }: { dataSource?: any }) {
238242
// ---- Widget config panel handlers ---------------------------------------
239243
const selectedWidget = editSchema?.widgets?.find((w) => w.id === selectedWidgetId);
240244

241-
// Stabilize widget config: only recompute when selecting a different widget
242-
// or after save — prevents useConfigDraft from resetting the draft on live preview updates.
245+
// Stabilize widget config: only recompute after explicit actions (widget
246+
// switch, save, add). configVersion is incremented on save/add, and
247+
// selectedWidgetId changes on widget switch — this prevents useConfigDraft
248+
// from resetting the draft on every live field change.
243249
const widgetConfig = useMemo(
244250
() => (selectedWidget ? flattenWidgetConfig(selectedWidget) : {}),
245251
// eslint-disable-next-line react-hooks/exhaustive-deps

0 commit comments

Comments
 (0)