Skip to content

fix: wire ViewConfigPanel toolbar toggles through to ListView#720

Merged
hotlong merged 3 commits intomainfrom
copilot/fix-toolbar-toggle-issue
Feb 22, 2026
Merged

fix: wire ViewConfigPanel toolbar toggles through to ListView#720
hotlong merged 3 commits intomainfrom
copilot/fix-toolbar-toggle-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 22, 2026

ViewConfigPanel's showSearch/showFilters/showSort toggles had no effect on the ListView toolbar — two data flow breaks prevented the flags from reaching the UI.

Break 1: renderListView schema missing toolbar flags

ObjectView.tsx (plugin-view) constructed the schema for renderListView without showSearch, showFilters, showSort, striped, bordered, or color:

// Before
return renderListView({
  schema: {
    type: 'list-view',
    objectName: schema.objectName,
    // ... filters, sort, rowHeight, densityMode, groupBy, options
    // ❌ no toolbar toggle flags
  },
});
// After
return renderListView({
  schema: {
    // ...existing props
    showSearch: activeView?.showSearch ?? schema.showSearch,
    showFilters: activeView?.showFilters ?? schema.showFilters,
    showSort: activeView?.showSort ?? schema.showSort,
    striped: activeView?.striped ?? (schema as any).striped,
    bordered: activeView?.bordered ?? (schema as any).bordered,
    color: activeView?.color ?? (schema as any).color,
  },
});

Break 2: ListView toolbar rendered unconditionally

ListView.tsx always rendered Search/Filter/Sort buttons regardless of schema flags. Now gated:

{schema.showFilters !== false && (<Popover>…Filter…</Popover>)}
{schema.showSort !== false && (<Popover>…Sort…</Popover>)}
{schema.showSearch !== false && (<div>…Search…</div>)}

!== false preserves default behavior — undefined/true show controls, only explicit false hides.

Tests

  • 7 new ListView tests: toolbar buttons hidden when showSearch/showFilters/showSort are false, visible when true or undefined
  • 2 new ObjectView tests: renderListView callback schema includes toolbar flags from both schema-level and activeView-level sources
Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: 右侧 ViewConfigPanel 设置开关无法控制左侧列表 toolbar — 数据流断裂全量排查与修复</issue_title>
<issue_description>## 🐛 问题描述

PR #716 合并后,右侧 ViewConfigPanel 的"启用搜索/启用筛选/启用排序"开关已经关闭(OFF 状态),但左侧列表的 toolbar(Hide fields、Filter、Group、Sort、Color、Comfortable、Search 等控件)仍然全部显示,开关完全无效

image1

🔍 根本原因

数据流存在 两处断裂

断裂点 1:PluginObjectView → renderListView schema 未传递 toolbar 开关

packages/plugin-view/src/ObjectView.tsxrenderListView 回调传给 Console 的 schema 缺少 showSearch/showFilters/showSort

// 当前代码(缺失 ❌)
if (renderListView) {
    return renderListView({
        schema: {
            type: 'list-view',
            objectName: schema.objectName,
            viewType: currentViewType,
            fields: ...,
            filters: mergedFilters,
            sort: mergedSort,
            rowHeight: activeView?.rowHeight,
            densityMode: activeView?.densityMode,
            groupBy: activeView?.groupBy,
            options: ...,
            // ❌ showSearch/showFilters/showSort 未传递!
        },
        ...
    });
}

断裂点 2:ListView toolbar 控件未根据 schema.showSearch/showFilters/showSort 条件渲染

packages/plugin-list/src/ListView.tsx 的 toolbar 渲染区域,Filter/Sort/Search/HideFields/Group/Color/Density 等按钮全部是无条件渲染的,完全没有检查 schema.showSearchschema.showFiltersschema.showSort 等字段来决定是否显示。

即使上游正确传递了 showSearch: false,ListView 自身也不会响应。


✅ 修复清单(逐项对照修改)

1. PluginObjectView — renderListView schema 补齐 toolbar 开关字段

  • renderListView({ schema }) 中添加:showSearch: activeView?.showSearch ?? schema.showSearch
  • renderListView({ schema }) 中添加:showFilters: activeView?.showFilters ?? schema.showFilters
  • renderListView({ schema }) 中添加:showSort: activeView?.showSort ?? schema.showSort
  • 同时补齐 stripedborderedcolor 到 renderListView schema(已部分在 Console fullSchema 补过,但 PluginObjectView 层也要传)

2. ListView — toolbar 控件条件渲染

  • Search 按钮/搜索框:当 schema.showSearch === false 时隐藏
  • Filter 按钮/弹窗:当 schema.showFilters === false 时隐藏
  • Sort 按钮/弹窗:当 schema.showSort === false 时隐藏
  • Hide Fields 按钮:检查是否需要受某个 config 控制(如 schema.showHideFields),如不需要则保持显示
  • Group 按钮:检查是否需要受 schema.showGroup 控制
  • Color 按钮:检查是否需要受 schema.showColor 控制
  • Density/行高 按钮:检查是否需要受 schema.showDensity 控制
  • Export 按钮:确认 schema.exportOptionsschema.allowExport 控制逻辑正确

3. Console ObjectView — renderListView 回调消费验证

  • Console 的 renderListView 构建 fullSchema 时,已有 showSearch: viewDef.showSearch ?? listSchema.showSearch——确认 listSchema 参数确实包含了 PluginObjectView 传来的值
  • 确认 fullSchema 最终传给 <ListView schema={fullSchema} /> 时,ListView 能正确消费

4. 数据流全链路校验

  • ViewConfigPanel onViewUpdate('showSearch', false)setViewDraftactiveView 更新
  • activeViewobjectViewSchema.showSearchPluginObjectView schema.showSearch
  • PluginObjectViewrenderListView({ schema: { showSearch } }) → Console fullSchema.showSearch
  • fullSchema<ListView schema={fullSchema} /> → toolbar Search 按钮隐藏
  • 同理验证 showFiltersshowSort 全链路

5. generateViewSchema(非 grid 视图直渲路径)

  • 对非 grid 类型(kanban/calendar/timeline/gallery/map/gantt),generateViewSchemabaseProps 已包含 showSearch/showSort/showFilters——确认这些值能传递到各子插件组件的 toolbar

6. useMemo 依赖项审查

  • Console objectViewSchema useMemo 的依赖数组包含 activeView?.showSearchactiveView?.showFiltersactiveView?.showSort
  • Plugin gridSchema useMemo 的依赖数组包含 activeView
  • Plugin renderContent 函数的 key 是否包含足够的 deps 以触发 re-render

7. 测试覆盖

  • 为 ListView 添加测试:showSearch: false 时 Search 按钮不渲染
  • 为 ListView 添加测试:showFilters: false 时 Filter 按钮不渲染
  • 为 ListView 添加测试:showSort: false 时 Sort 按钮不渲染
  • 为 PluginObjectView 添加测试:renderListView 回调的 schema 包含 showSearch/showFilters/showSort
  • 为 Console ObjectView 添加集成测试:右侧面板关闭 search/filter/sort → 左侧 toolbar 对应控件消失
  • 修复完成后运行全部 test suite,确认所有测试通过
  • 更新 Roadmap checklist

📂 涉及文件

文件 改动类型
packages/plugin-view/src/ObjectView.tsx renderListView schema 补齐 showSearch/showFilters/showSort
packages/plugin-list/src/ListView.tsx toolbar 控件条件渲染(Search/Filter/Sort/HideFields/Group/Color/Density)
apps/console/src/components/ObjectView.tsx 验证 fullSchema 传递正确性 + useMemo deps 审查
packages/plugin-list/src/__tests__/ListView.test.tsx 新增 toolbar 开关测试
packages/plugin-view/src/__tests__/ObjectView.test.tsx 新增 renderListView schema 传递测试

关联

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 22, 2026

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

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 22, 2026 0:49am
objectui-demo Ready Ready Preview, Comment Feb 22, 2026 0:49am
objectui-storybook Ready Ready Preview, Comment Feb 22, 2026 0:49am

Request Review

…conditionally render toolbar controls

- Add showSearch/showFilters/showSort/striped/bordered/color to renderListView schema in ObjectView.tsx (plugin-view)
- Conditionally render Search, Filter, Sort toolbar buttons in ListView.tsx based on schema flags
- Add 7 new tests for toolbar toggle visibility in ListView
- Add 2 new tests for renderListView schema propagation in ObjectView

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix toolbar controls not responding to ViewConfigPanel settings fix: wire ViewConfigPanel toolbar toggles through to ListView Feb 22, 2026
Copilot AI requested a review from hotlong February 22, 2026 12:45
@hotlong hotlong marked this pull request as ready for review February 22, 2026 12:52
Copilot AI review requested due to automatic review settings February 22, 2026 12:52
@hotlong hotlong merged commit 5a58d0d into main Feb 22, 2026
6 checks passed
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

Fixes the broken data flow between ViewConfigPanel toolbar toggles and the actual ListView toolbar by propagating showSearch/showFilters/showSort through ObjectViewrenderListView, and by conditionally rendering the corresponding toolbar controls in ListView.

Changes:

  • Add toolbar visibility flags (and some display props) to the schema passed into renderListView from packages/plugin-view’s ObjectView.
  • Gate ListView toolbar UI (Search/Filter/Sort) based on schema.showSearch/showFilters/showSort !== false.
  • Add unit tests covering flag propagation and toolbar visibility; update ROADMAP checklist entries.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/plugin-view/src/ObjectView.tsx Propagates toolbar toggle flags into renderListView schema (and attempts to propagate display props).
packages/plugin-view/src/tests/ObjectView.test.tsx Adds tests to verify renderListView schema includes/propagates toolbar flags.
packages/plugin-list/src/ListView.tsx Conditionally renders Filter/Sort/Search toolbar controls based on schema flags.
packages/plugin-list/src/tests/ListView.test.tsx Adds tests ensuring toolbar buttons hide/show based on schema flags.
ROADMAP.md Marks the toolbar toggle propagation + conditional rendering work as resolved.
Comments suppressed due to low confidence (2)

packages/plugin-list/src/ListView.tsx:887

  • On small screens the button label is hidden (hidden sm:inline), and the icon doesn’t provide an accessible name. Add an aria-label (and/or title) to the Filter trigger button so it remains accessible when rendered icon-only.
          {schema.showFilters !== false && (
          <Popover open={showFilters} onOpenChange={setShowFilters}>
            <PopoverTrigger asChild>
              <Button
                variant="ghost"
                size="sm"
                className={cn(
                  "h-7 px-2 text-muted-foreground hover:text-primary text-xs",
                  hasFilters && "text-primary"
                )}
              >
                <SlidersHorizontal className="h-3.5 w-3.5 mr-1.5" />
                <span className="hidden sm:inline">Filter</span>
                {hasFilters && (

packages/plugin-list/src/ListView.tsx:937

  • On small screens the button label is hidden (hidden sm:inline), and the icon doesn’t provide an accessible name. Add an aria-label (and/or title) to the Sort trigger button so it remains accessible when rendered icon-only.
          {schema.showSort !== false && (
          <Popover open={showSort} onOpenChange={setShowSort}>
            <PopoverTrigger asChild>
              <Button
                variant="ghost"
                size="sm"
                className={cn(
                  "h-7 px-2 text-muted-foreground hover:text-primary text-xs",
                  currentSort.length > 0 && "text-primary"
                )}
              >
                <ArrowUpDown className="h-3.5 w-3.5 mr-1.5" />
                <span className="hidden sm:inline">Sort</span>
                {currentSort.length > 0 && (

Comment on lines +821 to +823
striped: activeView?.striped ?? (schema as any).striped,
bordered: activeView?.bordered ?? (schema as any).bordered,
color: activeView?.color ?? (schema as any).color,
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

striped/bordered/color fall back to (schema as any) here, but ObjectViewSchema doesn’t define these fields at the top level (they live under schema.table or NamedListView). This means when activeView is undefined, the display props won’t propagate to renderListView as intended. Consider falling back to schema.table?.striped/schema.table?.bordered and (for color) currentNamedViewConfig?.color (or omit the schema fallback if there is no schema-level source).

Suggested change
striped: activeView?.striped ?? (schema as any).striped,
bordered: activeView?.bordered ?? (schema as any).bordered,
color: activeView?.color ?? (schema as any).color,
striped: activeView?.striped ?? schema.table?.striped,
bordered: activeView?.bordered ?? schema.table?.bordered,
color: activeView?.color ?? currentNamedViewConfig?.color,

Copilot uses AI. Check for mistakes.
Comment on lines 1033 to 1069
@@ -1064,6 +1069,7 @@ export const ListView: React.FC<ListViewProps> = ({
</Button>
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

On small screens the button label is hidden (hidden sm:inline), and the icon doesn’t provide an accessible name. Add an aria-label (and/or title) to the Search trigger button so it remains accessible when rendered icon-only.

Copilot uses AI. Check for mistakes.
Comment on lines +562 to +564
const renderListViewSpy = vi.fn(({ schema: listSchema }: any) => (
<div data-testid="custom-list">Custom ListView</div>
));
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

renderListViewSpy destructures schema: listSchema but never uses listSchema in this test, which can trip lint rules (no-unused-vars) and adds noise. Consider removing the destructuring or renaming it to _listSchema.

Copilot uses AI. Check for mistakes.
Comment on lines +587 to +589
const renderListViewSpy = vi.fn(({ schema: listSchema }: any) => (
<div data-testid="custom-list">Custom ListView</div>
));
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

renderListViewSpy destructures schema: listSchema but never uses listSchema in this test, which can trip lint rules (no-unused-vars) and adds noise. Consider removing the destructuring or renaming it to _listSchema.

Copilot uses AI. Check for mistakes.
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.

Bug: 右侧 ViewConfigPanel 设置开关无法控制左侧列表 toolbar — 数据流断裂全量排查与修复

3 participants