fix: wire ViewConfigPanel toolbar toggles through to ListView#720
fix: wire ViewConfigPanel toolbar toggles through to ListView#720
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…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>
There was a problem hiding this comment.
Pull request overview
Fixes the broken data flow between ViewConfigPanel toolbar toggles and the actual ListView toolbar by propagating showSearch/showFilters/showSort through ObjectView → renderListView, and by conditionally rendering the corresponding toolbar controls in ListView.
Changes:
- Add toolbar visibility flags (and some display props) to the schema passed into
renderListViewfrompackages/plugin-view’sObjectView. - Gate
ListViewtoolbar UI (Search/Filter/Sort) based onschema.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 anaria-label(and/ortitle) 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 anaria-label(and/ortitle) 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 && (
| striped: activeView?.striped ?? (schema as any).striped, | ||
| bordered: activeView?.bordered ?? (schema as any).bordered, | ||
| color: activeView?.color ?? (schema as any).color, |
There was a problem hiding this comment.
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).
| 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, |
| @@ -1064,6 +1069,7 @@ export const ListView: React.FC<ListViewProps> = ({ | |||
| </Button> | |||
There was a problem hiding this comment.
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.
| const renderListViewSpy = vi.fn(({ schema: listSchema }: any) => ( | ||
| <div data-testid="custom-list">Custom ListView</div> | ||
| )); |
There was a problem hiding this comment.
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.
| const renderListViewSpy = vi.fn(({ schema: listSchema }: any) => ( | ||
| <div data-testid="custom-list">Custom ListView</div> | ||
| )); |
There was a problem hiding this comment.
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.
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:
renderListViewschema missing toolbar flagsObjectView.tsx(plugin-view) constructed the schema forrenderListViewwithoutshowSearch,showFilters,showSort,striped,bordered, orcolor:Break 2: ListView toolbar rendered unconditionally
ListView.tsxalways rendered Search/Filter/Sort buttons regardless of schema flags. Now gated:!== falsepreserves default behavior —undefined/trueshow controls, only explicitfalsehides.Tests
showSearch/showFilters/showSortarefalse, visible whentrueorundefinedrenderListViewcallback schema includes toolbar flags from both schema-level and activeView-level sourcesOriginal 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 等控件)仍然全部显示,开关完全无效。
🔍 根本原因
数据流存在 两处断裂:
断裂点 1:PluginObjectView → renderListView schema 未传递 toolbar 开关
packages/plugin-view/src/ObjectView.tsx中renderListView回调传给 Console 的 schema 缺少 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.showSearch、schema.showFilters、schema.showSort等字段来决定是否显示。即使上游正确传递了
showSearch: false,ListView 自身也不会响应。✅ 修复清单(逐项对照修改)
1. PluginObjectView — renderListView schema 补齐 toolbar 开关字段
renderListView({ schema })中添加:showSearch: activeView?.showSearch ?? schema.showSearchrenderListView({ schema })中添加:showFilters: activeView?.showFilters ?? schema.showFiltersrenderListView({ schema })中添加:showSort: activeView?.showSort ?? schema.showSortstriped、bordered、color到 renderListView schema(已部分在 Console fullSchema 补过,但 PluginObjectView 层也要传)2. ListView — toolbar 控件条件渲染
schema.showSearch === false时隐藏schema.showFilters === false时隐藏schema.showSort === false时隐藏schema.showHideFields),如不需要则保持显示schema.showGroup控制schema.showColor控制schema.showDensity控制schema.exportOptions或schema.allowExport控制逻辑正确3. Console ObjectView — renderListView 回调消费验证
renderListView构建fullSchema时,已有showSearch: viewDef.showSearch ?? listSchema.showSearch——确认listSchema参数确实包含了 PluginObjectView 传来的值fullSchema最终传给<ListView schema={fullSchema} />时,ListView 能正确消费4. 数据流全链路校验
ViewConfigPanel onViewUpdate('showSearch', false)→setViewDraft→activeView更新activeView→objectViewSchema.showSearch→PluginObjectView schema.showSearchPluginObjectView→renderListView({ schema: { showSearch } })→ ConsolefullSchema.showSearchfullSchema→<ListView schema={fullSchema} />→ toolbar Search 按钮隐藏showFilters和showSort全链路5. generateViewSchema(非 grid 视图直渲路径)
generateViewSchema中baseProps已包含showSearch/showSort/showFilters——确认这些值能传递到各子插件组件的 toolbar6. useMemo 依赖项审查
objectViewSchemauseMemo 的依赖数组包含activeView?.showSearch、activeView?.showFilters、activeView?.showSortgridSchemauseMemo 的依赖数组包含activeViewrenderContent函数的key是否包含足够的 deps 以触发 re-render7. 测试覆盖
showSearch: false时 Search 按钮不渲染showFilters: false时 Filter 按钮不渲染showSort: false时 Sort 按钮不渲染renderListView回调的 schema 包含showSearch/showFilters/showSort📂 涉及文件
packages/plugin-view/src/ObjectView.tsxpackages/plugin-list/src/ListView.tsxapps/console/src/components/ObjectView.tsxpackages/plugin-list/src/__tests__/ListView.test.tsxpackages/plugin-view/src/__tests__/ObjectView.test.tsx关联
</issue_description>
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.