Skip to content

fix: dashboard config panel edits not reflected in live preview#862

Merged
hotlong merged 3 commits intomainfrom
copilot/fix-live-preview-issue
Feb 25, 2026
Merged

fix: dashboard config panel edits not reflected in live preview#862
hotlong merged 3 commits intomainfrom
copilot/fix-live-preview-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 25, 2026

Widget config panel edits to data binding fields (categoryField, valueField, aggregate, object) had no effect on the live preview when the widget had a data provider (widget.data.aggregate). The renderer read directly from the data provider config, which the config panel never touches.

Core fix: getComponentSchema() field precedence

In both DashboardRenderer and DashboardGridLayout, widget-level fields now override data provider config:

// Before: data provider config used directly, ignoring config panel edits
aggregate: widgetData.aggregate,
objectName: widgetData.object || widget.object,

// After: widget-level fields take precedence for live preview
const providerAgg = widgetData.aggregate;
const effectiveAggregate = providerAgg ? {
  field: widget.valueField || providerAgg.field,
  function: widget.aggregate || providerAgg.function,
  groupBy: widget.categoryField || providerAgg.groupBy,
} : undefined;
objectName: widget.object || widgetData.object,
aggregate: effectiveAggregate,

This also fixes objectName precedence for table/pivot widgets (same widgetData.object || widget.objectwidget.object || widgetData.object reversal).

DashboardWithConfig missing design mode wiring

DashboardWithConfig defined handleWidgetSelect but never passed designMode/selectedWidgetId/onWidgetClick to DashboardRenderer, making widget selection impossible in the plugin-level component.

Tests

  • 6 new tests for widget-level field override behavior (groupBy, field, function, objectName, table objectName, simultaneous overrides)
  • 2 new tests for DashboardWithConfig design mode (overlay presence, widget click-to-select)
Original prompt

This section details on the original issue you should resolve

<issue_title>Dashboard右侧编辑器修改时左侧无法实时预览效果(排查所有导致Live Preview失效的原因)</issue_title>
<issue_description>## 问题描述
在Dashboard编辑页面,右侧Widget配置面板(如数据绑定、聚合、布局等字段)编辑时,左侧主区域预览不会实时反映修改效果。

见如下截图:
编辑右侧无预览效果

已知排查点

  1. editSchema修改流

    • 右侧配置面板通过useConfigDraft管理草稿,字段修改后调用onFieldChange更新editSchema
    • previewSchema = editSchema || dashboard 应该驱动 DashboardRenderer 重新渲染新 schema。
  2. DashboardRenderer组件

    • 能否响应schema prop更新,重新渲染所有widgets。
    • 是否有memoization导致局部widget渲染不及时?
  3. SchemaRenderer内容

    • 是否依赖外部数据(如dataSource),配置项变更时数据refetch有无触发?
    • widget的component对象内容是否发生深拷贝/identity change,有无因为React浅对比失效。
  4. 配置面板与左侧渲染分离

    • Memoization策略(如widgetConfigeditSchemaconfigVersion)是否导致预览不同步。
  5. 其它场景补充

    • 多widget、嵌套widget或复杂数据源场景是否存在预览失效。
    • 浏览器端不同屏幕/移动端等是否会出现此问题。

建议排查步骤

  • 检查handleWidgetFieldChange是否完全驱动预览流。(setEditSchema后预览是否变化?)
  • DashboardRenderer内部是否对schema/widgets有深度响应。
  • widget/component config是否因memo或引用不变导致无法更新UI。
  • SchemaRenderer及widget自身数据依赖是否有副作用。
  • 编辑panel与主panel之间通信流是否一致且能触发重绘。

相关代码分析摘要

  • 右侧ConfigPanel编辑通过useConfigDraft回调驱动editSchema。
  • 左侧DashboardRenderer响应editSchema为previewSchema。
  • DashboardRenderer渲染schema.widgets,但组件渲染或数据绑定可能未刷新。

优先级

  • plugin: editor
  • bug

开发任务完成后请运行相关test并更新roadmap。</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 25, 2026 9:06am
objectui-demo Ready Ready Preview, Comment Feb 25, 2026 9:06am
objectui-storybook Ready Ready Preview, Comment Feb 25, 2026 9:06am

Request Review

- DashboardRenderer/DashboardGridLayout getComponentSchema() now merges
  widget-level fields (categoryField, valueField, aggregate, object) with
  data provider config, with widget-level fields taking precedence
- Fixes objectName precedence for table/pivot widget types
- DashboardWithConfig now passes designMode/selectedWidgetId/onWidgetClick
  to DashboardRenderer to enable widget selection and live preview
- Added 8 new tests for live preview field override behavior

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…for live preview

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong hotlong marked this pull request as ready for review February 25, 2026 08:49
Copilot AI review requested due to automatic review settings February 25, 2026 08:49
Copilot AI changed the title [WIP] Fix live preview issue in Dashboard editor fix: dashboard config panel edits not reflected in live preview Feb 25, 2026
@hotlong hotlong merged commit ddc2d06 into main Feb 25, 2026
3 of 5 checks passed
Copilot AI requested a review from hotlong February 25, 2026 08:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the live preview issue in the Dashboard editor where widget configuration changes (categoryField, valueField, aggregate, object) made in the right-side config panel were not immediately reflected in the left-side preview when widgets used data providers. The fix ensures widget-level fields take precedence over data provider configuration for real-time preview updates.

Changes:

  • Modified getComponentSchema() in DashboardRenderer and DashboardGridLayout to merge widget-level fields with data provider config, giving widget fields precedence
  • Updated DashboardWithConfig to pass designMode, selectedWidgetId, and onWidgetClick props to DashboardRenderer for widget selection support
  • Added 10 comprehensive tests covering field override scenarios and design mode functionality

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/plugin-dashboard/src/DashboardRenderer.tsx Fixed widget field precedence: widget.object, categoryField, valueField, and aggregate now override data provider config for live preview
packages/plugin-dashboard/src/DashboardGridLayout.tsx Applied identical fix to grid layout variant for consistency
packages/plugin-dashboard/src/DashboardWithConfig.tsx Added designMode, selectedWidgetId, and onWidgetClick props to enable widget selection in config editor
packages/plugin-dashboard/src/__tests__/DashboardRenderer.widgetData.test.tsx Added 8 tests validating widget-level field override behavior for charts and tables
packages/plugin-dashboard/src/__tests__/DashboardWithConfig.test.tsx Added 2 tests verifying design mode and widget selection functionality
ROADMAP.md Documented Phase 12 completion: data provider field override for live preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard右侧编辑器修改时左侧无法实时预览效果(排查所有导致Live Preview失效的原因)

3 participants