Skip to content

ViewConfigPanel: add column reorder support in field selector - #694

Merged
hotlong merged 3 commits into
mainfrom
copilot/add-columns-selector-subpanel
Feb 21, 2026
Merged

ViewConfigPanel: add column reorder support in field selector#694
hotlong merged 3 commits into
mainfrom
copilot/add-columns-selector-subpanel

Conversation

CopilotAI commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

Column selector in ViewConfigPanel only supported toggle visibility — no way to reorder columns. Users couldn't customize display order from the config panel.

Changes

  • Column reorder: handleColumnMove(fieldName, 'up' | 'down') swaps adjacent items in draft.columns, propagates via onViewUpdate for real-time preview
  • Two-section column selector UI: Selected columns render first (in draft order) with ↑/↓ buttons; unselected fields shown below for adding. Boundary buttons disabled appropriately.
  • EditorPanelType export: 'columns' | 'filter' | 'sort' — typed sub-panel identifiers for parent state management
  • 8 new tests: Reorder up/down, boundary disabled states, save persistence, unselected field addition, onViewUpdate propagation
// Selected columns with reorder controls<divdata-testid="selected-columns">{draft.columns.map((colName,idx)=>(<divkey={colName}><CheckboxcheckedonCheckedChange={()=>handleColumnToggle(colName,false)}/><span>{field?.label}</span><buttondisabled={idx===0}onClick={()=>handleColumnMove(colName,'up')}><ArrowUp/></button><buttondisabled={idx===draft.columns.length-1}onClick={()=>handleColumnMove(colName,'down')}><ArrowDown/></button></div>))}</div>
Original prompt

This section details on the original issue you should resolve

<issue_title>ViewConfigPanel支持Columns字段选择器子面板,完善onOpenEditor联动</issue_title>
<issue_description># 问题说明
当前点击ViewConfigPanel中的"字段列(Columns)"配置行,仅触发 onOpenEditor 回调并 console.info,无法弹出实际可用的字段勾选/排序面板。用户无法通过配置面板自定义列的显示与顺序,功能割裂且无法所见即所得。

建议修复方案

  • ObjectView 中添加 const [activeEditor, setActiveEditor] = useState<EditorPanelType | null>(null);
  • 实现 handleOpenEditor: 点击"字段列(Columns)"时 setActiveEditor('columns'),并渲染一个浮层/侧边栏作为子面板
  • 面板内列出 all objectDef.fields,支持勾选、拖拽排序,Save后更新 draft.columns 并回传
  • 增加测试用例:点击后panel展开,拖拽/勾选列可更新,保存生效

验收/测试点

  • Columns面板"字段列"可选择和排序,并影响视图列
  • 修改后draft.columns同步反映到主列表显示顺序
  • 联动原有的 onViewUpdate 通道,支持即时反馈

/cc @hotlong</issue_description>

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


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@vercel

vercelBot commented Feb 21, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
objectuiCanceledCanceledFeb 21, 2026 9:05am
objectui-demoReadyReadyPreview, CommentFeb 21, 2026 9:05am
objectui-storybookReadyReadyPreview, CommentFeb 21, 2026 9:05am

Request Review

- Export EditorPanelType type for sub-panel state management
- Add handleColumnMove for column up/down reordering
- Enhanced column selector shows selected columns with move buttons
- Unselected fields shown separately for easy addition
- All changes propagate via onViewUpdate for real-time preview
- Added 9 new test cases covering reorder, save, and edge cases
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
CopilotAI changed the title [WIP] Add Columns field selector sub-panel to ViewConfigPanelViewConfigPanel: add column reorder support in field selectorFeb 21, 2026
CopilotAI requested a review from hotlongFebruary 21, 2026 09:00
@hotlong
hotlong marked this pull request as ready for review February 21, 2026 09:07
CopilotAI review requested due to automatic review settings February 21, 2026 09:07
@hotlong
hotlong merged commit 5c08c0b into mainFeb 21, 2026
5 checks passed

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds column reordering controls to the ViewConfigPanel column selector so users can both toggle visibility and adjust display order with immediate preview updates.

Changes:

  • Added handleColumnMove(fieldName, 'up' | 'down') to swap adjacent entries in draft.columns and propagate via onViewUpdate.
  • Updated the Fields/Columns selector UI to a two-section layout: selected columns (ordered, with ↑/↓ controls) and unselected fields (add-only).
  • Added column reorder/addition/persistence tests and updated the roadmap item to completed.

Reviewed changes

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

FileDescription
apps/console/src/components/ViewConfigPanel.tsxImplements column move logic and updates the column selector UI to support reordering.
apps/console/src/tests/ViewConfigPanel.test.tsxAdds tests covering reorder behavior, boundary disabled states, save persistence, and real-time updates.
ROADMAP.mdMarks column reorder in ViewConfigPanel as completed.
Comments suppressed due to low confidence (2)

apps/console/src/components/ViewConfigPanel.tsx:609

  • In the selected-columns render, using key={colName} can break React reconciliation if draft.columns ever contains duplicates (e.g., from persisted config), and indexOf-based move/remove will also behave unexpectedly. Consider normalizing draft.columns to unique values on load (or use a stable unique key such as ${colName}-${idx} and de-dupe before rendering/updating).
 {draft.columns.map((colName: string, idx: number) => {
const field = fieldOptions.find(f => f.value === colName);
return (
<div key={colName} className="flex items-center gap-1 text-xs hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1">
<Checkbox

apps/console/src/components/ViewConfigPanel.tsx:607

  • Rendering each selected column does a fieldOptions.find(...) lookup, which becomes O(selectedColumns × fields) on every render. For objects with many fields this can add noticeable overhead; consider precomputing a Map/record of field metadata keyed by value (useMemo) and reading from it in the loop.
 {draft.columns.map((colName: string, idx: number) => {
const field = fieldOptions.find(f => f.value === colName);
return (

Sign up for freeto 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.

ViewConfigPanel支持Columns字段选择器子面板,完善onOpenEditor联动

3 participants

@hotlong