Skip to content

列表右侧面板问题汇总 #722

Description

@hotlong

让我先深入排查每一个控件和属性的完整数据流。现在我已经完整阅读了四个核心文件的最新代码,下面给出深度排查的完整清单:


深度排查完整清单

📊 整体数据流路径

ViewConfigPanel.updateDraft(field, value)
  → Console.handleViewUpdate(field, value) → setViewDraft({ [field]: value })
    → activeView = { ...baseView, ...viewDraft }  ← 合并生效
      → objectViewSchema.showSearch/showFilters/showSort  ← ✅ 已同步
        → PluginObjectView schema prop
          → renderContent() → renderListView({ schema: { showSearch, ... } })  ← ✅ 已传递
            → Console.renderListView → fullSchema.showSearch = viewDef.showSearch ?? listSchema.showSearch  ← ✅ 已传递
              → <ListView schema={fullSchema} />
                → ListView toolbar 条件渲染  ← ⚠️ 部分生效,部分未生效

逐控件排查结果

# 控件 ViewConfigPanel 开关 Console 传递 PluginObjectView 传递 ListView 消费 状态
1 Search showSearch ✅ fullSchema.showSearch ✅ L307 renderListView schema.showSearch ✅ L817 schema.showSearch !== false ✅ L1033 ✅ 生效
2 Filter showFilters ✅ fullSchema.showFilters ✅ L309 renderListView schema.showFilters ✅ L818 schema.showFilters !== false ✅ L874 ✅ 生效
3 Sort showSort ✅ fullSchema.showSort ✅ L308 renderListView schema.showSort ✅ L819 schema.showSort !== false ✅ L924 ✅ 生效
4 Hide Fields ❌ 无开关 ❌ 未传递 ❌ 未传递 无条件渲染 L817-871 ❌ 始终显示,无法控制
5 Group ❌ 无开关 ❌ 未传递 ❌ 未传递 无条件渲染(disabled)L912-921 ❌ 始终显示,无法控制
6 Color 面板仅设颜色字段 ❌ 无 showColor ❌ 无 showColor 无条件渲染(disabled)L962-971 ❌ 始终显示,无法控制
7 Density/行高 面板设 rowHeight 值 fullSchema.densityMode ✅ L301 schema.densityMode ✅ L813 无条件渲染 L973-983
密度值通过 useDensityMode 消费
⚠️ 按钮始终显示,值同步正常
8 Export allowExport 开关 ✅ ❌ 未转为 exportOptions ❌ 未传递 schema.exportOptions && L986 控制 ❌ 面板开关无效
9 Share ❌ 无开关 ❌ 未传递 ❌ 未传递 schema.sharing?.enabled L1018 控制 ⚠️ 无面板入口
10 Striped 斑马纹 ❌ 无面板开关 fullSchema.striped ✅ L310 schema.striped ✅ L821 传递到子视图 schema 但 ListView 未用 ⚠️ 面板无入口
11 Bordered 边框 ❌ 无面板开关 fullSchema.bordered ✅ L311 schema.bordered ✅ L822 传递到子视图 schema 但 ListView 未用 ⚠️ 面板无入口
12 Row Height 行高 rowHeight 选择器 ✅ fullSchema.rowHeight ✅ L300 schema.rowHeight ✅ L812 useDensityMode(resolvedDensity) ✅ L342-354 ✅ 值生效
13 Density Mode ❌ 无独立面板入口 fullSchema.densityMode ✅ L301 schema.densityMode ✅ L813 useDensityMode(resolvedDensity) ✅ L342-354 ✅ 值生效(通过 rowHeight 映射)
14 Inline Edit editRecordsInline ✅ fullSchema.inlineEdit ✅ L302 ❌ 未传递到 renderListView schema schema.inlineEdit != null ? editable L622 ⚠️ 值同步但 PluginObjectView 层未传
15 Click Into Details clickIntoRecordDetails ✅ ❌ 未传递 ❌ 未传递 ❌ ListView 不消费 ❌ 完全无效
16 Add Record Via Form addRecordViaForm ✅ ❌ 未传递 ❌ 未传递 ❌ ListView 不消费 ❌ 完全无效
17 Wrap Headers wrapHeaders ✅ ❌ 未传递 ❌ 未传递 ❌ ListView 不消费 ❌ 完全无效
18 Show Description showDescription ✅ fullSchema.appearance.showDescription ✅ L303-305 ❌ 未传递到 renderListView schema ❌ ListView 不消费 appearance ❌ 完全无效
19 Collapse All By Default collapseAllByDefault ✅ ❌ 未传递 ❌ 未传递 ❌ ListView 不消费 ❌ 完全无效
20 Field Text Color fieldTextColor ✅ ❌ 未传递 ❌ 未传递 ❌ ListView 不消费 ❌ 完全无效
21 Prefix Field prefixField ✅ ❌ 未传递 ❌ 未传递 ❌ ListView 不消费 ❌ 完全无效
22 Add/Delete Inline addDeleteRecordsInline ✅ ❌ 未传递 ❌ 未传递 ❌ ListView 不消费 ❌ 完全无效

🔴 关键 Bug 汇总(必须修复)

Bug 1: Hide Fields / Group / Color 按钮始终无条件显示

位置: ListView.tsx L816-971
原因: 这 3 个 toolbar 按钮没有任何条件判断,永远渲染
修复: 需要新增 schema 属性(如 showHideFields、showGroup、showColor)并在 ListView 中条件渲染,或统一用一个 toolbarControls 配置

Bug 2: Export 开关断裂

位置: ViewConfigPanel 写入 allowExport: boolean,但 ListView 检查的是 schema.exportOptions 对象
原因: 两端用了不同的字段名/类型,Console 也没有将 allowExport 转换为 exportOptions
修复: Console fullSchema 需要 exportOptions: viewDef.allowExport ? { formats: ['csv', 'json'] } : undefined

Bug 3: Density/行高按钮无法隐藏

位置: ListView.tsx L973-983
原因: 密度按钮无条件渲染(且永远显示在 toolbar)
修复: 需��新增 showDensity schema 属性

Bug 4: PluginObjectView renderListView 缺少多个属性

位置: PluginObjectView.tsx L802-829 的 renderContent()
缺少传递: inlineEdit、appearance(showDescription)、wrapHeaders、clickIntoRecordDetails、addRecordViaForm、collapseAllByDefault、fieldTextColor、prefixField、addDeleteRecordsInline
修复: 补齐所有属性到 renderListView schema

Bug 5: ListView 不消费大量已传递属性

位置: ListView.tsx 整体
未消费: striped、bordered、color、appearance、wrapHeaders、fieldTextColor、clickIntoRecordDetails、addRecordViaForm 等
修复: ListView 需要将这些 prop 转发到 viewComponentSchema 中传给子组件(ObjectGrid 等)

Bug 6: objectViewSchema useMemo 依赖不完整

位置: Console ObjectView.tsx L392-406
问题: 只依赖了 activeView?.showSearch、showFilters、showSort,但没有依赖 striped、bordered、color、rowHeight、densityMode 等——不过这些值走的是 renderListView 路径,所以影响有限。renderListView useCallback 依赖 [activeView, ...] 已经涵盖。
严重性: 低

Bug 7: ViewConfigPanel 的 hasExport 逻辑有 bug

位置: ViewConfigPanel.tsx L323

const hasExport = draft.exportOptions !== undefined || draft.allowExport !== false;

当 draft.allowExport 为 undefined(未设置)时,undefined !== false 为 true,导致导出开关始终显示为 ON。
修复: 应改为 draft.allowExport === true 或 draft.exportOptions != null || draft.allowExport === true


🟡 非关键问题(建议修复)

# 问题 说明
A ViewConfigPanel 缺少 striped/bordered 开关 面板配置了 color/rowHeight 但没有斑马纹/边框开关
B 面板缺少 Density Mode 独立选项 只有 rowHeight 选择器,无法直接设置 compact/comfortable/spacious
C 面板缺少 Share/Sharing 配置入口 ListView 已支持 sharing.enabled 但面板无法配置
D clickIntoRecordDetails / addRecordViaForm 端到端未实现 面板有开关但整条链路无组件消费
E wrapHeaders、collapseAllByDefault、fieldTextColor、prefixField 完全是空壳 面板可设值但没有任何组件消费

✅ 确认已生效的(3 个)

  1. Search — 全链路 ✅
  2. Filter — 全链路 ✅
  3. Sort — 全链路 ✅

我现在来更新 Issue #719,将这份完整排查清单补充进去。深度排查完成。我仔细阅读了四个核心文件的完整源码后,得出以下完整结论:


🔍 深度排查报告:ViewConfigPanel → ListView toolbar 控件全链路

一、整体数据流

ViewConfigPanel.updateDraft('showSearch', false)
    ↓
Console.handleViewUpdate → setViewDraft({showSearch: false})
    ↓
activeView = {...baseView, ...viewDraft}  ← 合并生效 ✅
    ↓
objectViewSchema = { showSearch: activeView?.showSearch !== false } ← 传给 PluginObjectView ✅
    ↓
PluginObjectView.renderContent → renderListView({ schema: { showSearch: activeView?.showSearch ?? schema.showSearch } }) ✅
    ↓
Console.renderListView → fullSchema = { showSearch: viewDef.showSearch ?? listSchema.showSearch } ✅
    ↓
<ListView schema={fullSchema} />
    ↓
ListView.tsx toolbar 条件渲染 ← 🔑 关键终端

二、逐控件排查清单

# 控件 ViewConfigPanel 字段 Console fullSchema 透传 ListView 条件渲染 当前状态 问题详情
1 Search showSearch ✅ L307 ✅ L1033: schema.showSearch !== false ✅ 应该生效 数据流完整,如果不生效需检查运行时值
2 Filter showFilters ✅ L309 ✅ L874: schema.showFilters !== false ✅ 应该生效 数据流完整
3 Sort showSort ✅ L308 ✅ L924: schema.showSort !== false ✅ 应该生效 数据流完整
4 Hide Fields ❌ 无对应字段 ❌ 未透传 ❌ L817 无条件渲染,始终显示 ❌ 无法控制 需新增 showHideFields
5 Group ❌ 无对应字段 ❌ 未透传 ❌ L913 无条件渲染,始终显示(disabled) ❌ 无法控制 需新增 showGroup
6 Color ❌ 无对应字段 color 透传是字段值,不是开关 ❌ L963 无条件渲染,始终显示(disabled) ❌ 无法控制 需新增 showColor
7 Density/行高 rowHeight(值控制) ✅ L300 rowHeight透传 ❌ L974 无条件渲染,始终显示 ❌ 无法控制显隐 需新增 showDensity
8 Export allowExport / exportOptions ❌ 未透传 allowExport/exportOptions ⚠️ L986 仅判断 schema.exportOptions 有无 ❌ 不生效 Console fullSchema 未传 exportOptions/allowExport
9 Share ❌ 无对应字段 ❌ 未透传 ⚠️ L1018 仅判断 schema.sharing?.enabled ❌ 无法控制 需新增
10 User Filters 行 ❌ 无对应字段 ❌ ❌ L1105 始终显示(如有 objectDef 字段) ❌ 无法控制 受 objectDef 自动派生
11 Quick Filters 行 ❌ 无对应字段 ❌ ⚠️ L1079 仅判断 schema.quickFilters 有无 N/A 依赖 schema 配置,不受面板控制

三、截图中可见的所有 toolbar 控件

从截图可以看到左侧 toolbar 显示:Hide fields | Filter | Group | Sort 1 | Color | Comfortable | Search

以及下方 User Filters 行:Status | Priority | Lead Source | Do Not Call | Active | + Add filter

截图控件 对应 ListView 代码 面板开关是否能控制
Hide fields L817 无条件 ❌ 始终显示
Filter L874 showFilters !== false ✅ 应能隐藏
Group L913 无条件(disabled) ❌ 始终显示
Sort 1 L924 showSort !== false ✅ 应能隐藏
Color L963 无条件(disabled) ❌ 始终显示
Comfortable L974 无条件 ❌ 始终显示
Search L1033 showSearch !== false ✅ 应能隐藏
User Filters 行 L1105 自动派生 ❌ 无法控制

四、为什么"大部分还是没效果"

核心原因:截图中 7 个 toolbar 控件中,只有 Filter、Sort、Search 这 3 个有条件渲染。另外 4 个(Hide fields、Group、Color、Density)始终显示,不受任何 schema 属性控制。加上 User Filters 行也不受控,所以用户感觉"大部分没效果"。

五、完整修复 Checklist

A. ListView.tsx — 需要新增条件渲染的控件

  • Hide Fields 按钮:新增 schema.showHideFields !== false && 包裹 L817-L871
  • Group 按钮:新增 schema.showGroup !== false && 包裹 L912-L921
  • Color 按钮:新增 schema.showColor !== false && 包裹 L962-L971
  • Density 按钮:新增 schema.showDensity !== false && 包裹 L973-L983
  • User Filters 行:新增 schema.showUserFilters !== false && 包裹 L1104-L1114

B. Console ObjectView fullSchema — 需要补齐透传

  • showHideFields: viewDef.showHideFields ?? listSchema.showHideFields
  • showGroup: viewDef.showGroup ?? listSchema.showGroup
  • showColor: viewDef.showColor ?? listSchema.showColor
  • showDensity: viewDef.showDensity ?? listSchema.showDensity
  • showUserFilters: viewDef.showUserFilters ?? listSchema.showUserFilters
  • exportOptions: viewDef.allowExport === false ? undefined : (viewDef.exportOptions ?? listSchema.exportOptions)
  • allowExport: viewDef.allowExport ?? listSchema.allowExport

C. PluginObjectView renderContent schema — 需要补齐透传

  • 同上所有新增字段均需在 L816-L823 区域添加

D. ViewConfigPanel — 需要新增开关

  • 新增 showHideFields toggle("启用隐藏字段"开关)
  • 新增 showGroup toggle("启用分组"开关)
  • 新增 showColor toggle("启用颜色"开关)
  • 新增 showDensity toggle("启用行高调整"开关)
  • 新增 showUserFilters toggle("启用用户筛选器"开关)

E. ListViewSchema 类型定义 — 需要扩展

  • 在 @object-ui/types ListViewSchema 接口新增:showHideFields?, showGroup?, showColor?, showDensity?, showUserFilters?, allowExport?

F. 测试

  • 为每个新增条件渲染编写单元测试
  • 端到端测试:面板每个开关 → 对应 toolbar 控件显隐
  • 运行全量 test suite

现在我来更新 Issue #719 的内容,纳入以上完整排查结果。好的,深度排查已完成。以下是对现有代码的 全量逐控件排查报告:


🔬 深度排查结果:ViewConfigPanel → ListView toolbar 控件全链路

数据流总结

ViewConfigPanel → updateDraft(field, value) → setViewDraft
    ↓
Console activeView (merge baseView + draft)
    ↓
objectViewSchema (useMemo) ← showSearch/showFilters/showSort ✅ 已传入
    ↓
PluginObjectView (schema prop)
    ↓
renderListView({ schema: { showSearch, showFilters, showSort, ... } }) ✅ 已传入
    ↓
Console renderListView → fullSchema ✅ 已传入
    ↓
<ListView schema={fullSchema} />
    ↓
ListView.tsx toolbar 条件渲染 ← ⚠️ 部分控件未受控

逐控件排查明细

# 控件 面板开关 schema属性 ListView消费 状态 断裂原因
1 Search 搜索 ✅ toggle-showSearch showSearch ✅ schema.showSearch !== false (L1033) ✅ 已生效 —
2 Filter 筛选 ✅ toggle-showFilters showFilters ✅ schema.showFilters !== false (L874) ✅ 已生效 —
3 Sort 排序 ✅ toggle-showSort showSort ✅ schema.showSort !== false (L924) ✅ 已生效 —
4 Hide Fields ❌ 无开关 ❌ 无属性 ❌ 无条件渲染 (L817) ⛔ 永远显示 缺少 showHideFields 属性,按钮始终渲染
5 Group 分组 ❌ 无开关 ❌ 无属性 ❌ 无条件渲染 (L912) ⛔ 永远显示(disabled) 缺少 showGroup 属性,按钮写死 disabled 渲染
6 Color 颜色 面板有 color 选择器 color(值非开关) ❌ 无条件渲染 (L962) ⛔ 永远显示(disabled) 缺少 showColor 开关,按钮写死 disabled 渲染
7 Density 行高 面板有 rowHeight 选择器 densityMode/rowHeight(值非开关) ❌ 无条件渲染 (L973) ⛔ 永远显示 缺少 showDensity 开关,始终渲染
8 Export 导出 ✅ toggle-allowExport exportOptions/allowExport ⚠️ schema.exportOptions && (L986) ⚠️ 不完全生效 面板写 allowExport 但 ListView 只检查 exportOptions 是否存在,二者不联动
9 Share 分享 ❌ 无开关 sharing.enabled ✅ schema.sharing?.enabled (L1018) ⚠️ 面板无控制 schema 属性存在但面板无 UI
10 View Switcher ❌ 无开关 showViewSwitcher prop ✅ showViewSwitcher && (L803) ✅ 但面板无控 默认 false,非面板控制项

详细分析

✅ 已生效的 3 个控件(Search / Filter / Sort)

          {/* Filter */}
          {schema.showFilters !== false && (
          <Popover open={showFilters} onOpenChange={setShowFilters}>
            ...
          </Popover>
          )}
          {/* Sort */}
          {schema.showSort !== false && (
          <Popover open={showSort} onOpenChange={setShowSort}>
            ...
          </Popover>
          )}
        {/* Right: Search */}
        {schema.showSearch !== false && (
        <div className="flex items-center gap-1">
          ...
        </div>
        )}

这 3 个控件已正确受 schema 控制。 如果你在���际测试中发现它们不生效,问题可能在于 !== false 的判断逻辑:当 ViewConfigPanel 切换开关到 OFF 时,updateDraft('showSearch', false) 确实会将值设为 false,但初始值如果未定义(undefined),undefined !== false 为 true,所以默认就是显示。这个逻辑是正确的。

⛔ 完全无条件渲染的 4 个控件

Hide Fields(L817) — 始终渲染,无任何开关:

          {/* Hide Fields */}
          <Popover open={showHideFields} onOpenChange={setShowHideFields}>
            {/* 没有任何 schema.showXxx 条件判断,始终渲染 */}

Group(L912) — 始终渲染且 disabled:

          {/* Group */}
          <Button variant="ghost" size="sm" disabled>
            {/* 硬编码 disabled,无任何 schema 条件 */}

Color(L962) — 始终渲染且 disabled:

          {/* Color */}
          <Button variant="ghost" size="sm" disabled>
            {/* 硬编码 disabled,无任何 schema 条件 */}

Density(L973) — 始终渲染:

          {/* Row Height / Density Mode */}
          <Button variant="ghost" size="sm" onClick={density.cycle}>
            {/* 始终渲染,无任何 schema 条件 */}

⚠️ Export 不联动的根因

ViewConfigPanel 设置的是 allowExport: boolean,但 ListView 判断的是 schema.exportOptions 对象是否存在:

          {schema.exportOptions && (
            <Popover>...</Popover>
          )}

当面板关闭 allowExport 时,schema.exportOptions 仍然可能是一个对象 {},所以 Export 按钮依然显示。


🧾 完整修复 Checklist

A. 需要在 ListView.tsx 添加条件渲染的控件(4 个新增 + 1 个修复):

  • Hide Fields 按钮:用 schema.showHideFields !== false && 包裹
  • Group 按钮:用 schema.showGroup !== false && 包裹(或 schema.groupBy 存在时才显示)
  • Color 按钮:用 schema.showColor !== false && 包裹
  • Density 按钮:用 schema.showDensity !== false && 包裹
  • Export 按钮:修改判断为 (schema.exportOptions && schema.allowExport !== false) &&

B. 需要在 ViewConfigPanel 添加的新开关(4 个):

  • showHideFields 开关
  • showGroup 开关
  • showColor 开关
  • showDensity 开关

C. 需要在 ListViewSchema 类型定义中添加的字段:

  • showHideFields?: boolean
  • showGroup?: boolean
  • showColor?: boolean
  • showDensity?: boolean
  • allowExport?: boolean

D. 需要全链路透传的属性(Console renderListView fullSchema):

  • 新增属性 showHideFields, showGroup, showColor, showDensity, allowExport 到 fullSchema

E. 测试覆盖:

  • 为每个新增开关添加测试:开关 OFF 时对应 toolbar 按钮不渲染
  • 验证 Export 联动修复
  • 运行全部 test suite

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions