Skip to content

fix: 添加grid column 组件的type="operation" 和 operationConfig的文档, 删除无用缓存代码#4231

Open
shenjunjian wants to merge 2 commits into
devfrom
shen/add-grid-column-type
Open

fix: 添加grid column 组件的type="operation" 和 operationConfig的文档, 删除无用缓存代码#4231
shenjunjian wants to merge 2 commits into
devfrom
shen/add-grid-column-type

Conversation

@shenjunjian

@shenjunjian shenjunjian commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

PR

  1. 补充gridColumn的文档, 漏掉了type和 operationConfig属性介绍
  2. 补充operationConfig的示例
  3. 兼容 dropdown 的item-click事件
  4. 删除重构时,引入的无用缓存代码

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added an "operation" column type for grids with configurable multi-button operations per row.
    • New operation-config prop lets you define buttons, icons, click handlers, visibility/disabled rules, and max buttons.
  • Documentation

    • Added demos showing operation-column usage, sample data, and dynamic per-row button behavior.
  • Refactor

    • Internal render compatibility improvements to better support operation-column behavior.

@github-actions github-actions Bot added the bug Something isn't working label Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e6f0eccd-0f0d-4dc4-a6b3-090bd6072638

📥 Commits

Reviewing files that changed from the base of the PR and between 1393625 and d31c44d.

📒 Files selected for processing (1)
  • examples/sites/demos/apis/grid.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/sites/demos/apis/grid.js

Walkthrough

Adds an operation column type to the grid API with operation-config typing, provides Composition and Options API demos plus demo registration, and cleans up internal cell rendering to support operation column data shapes and click handling.

Changes

Operation Column Feature Implementation

Layer / File(s) Summary
Operation column API and types
examples/sites/demos/apis/grid.js
grid-column type prop extended to 'operation', new operation-config prop defined with IOperationConfig describing buttons, optional max, render, and disabledClass; width demo mapping updated and ICustomConfig code block adjusted.
Operation column Composition API demo
examples/sites/demos/pc/app/grid/operation-column/operation-column-composition-api.vue
Composition API example: tiny-grid with index, operation, and data columns; operationConfig defines five icon buttons with per-row hidden/disabled rules and two click handlers (modal + toggle flag, modal only).
Operation column Options API demo
examples/sites/demos/pc/app/grid/operation-column/operation-column.vue
Options API example: tiny-grid with operation column driven by operationConfig, icon buttons, modal-driven click handlers, and sample tableData demonstrating visibility/disabled behaviors.
Demo registration
examples/sites/demos/pc/app/grid/webdoc/grid-operation-column.js
Registers new demo entry operation-column with localized descriptions and codeFiles reference to the demo component.
Internal cell rendering cleanup and operation support
packages/vue/src/grid/src/cell/src/cell.ts
Removes getColumnSlotRender and columnSlotsWeakMap caching, removes unused level param from renderIndexCell, and updates handleItemClick to support nested itemData.itemData.name extraction for operation-column handlers.

Sequence Diagram

sequenceDiagram
  participant User
  participant OperationButton as Operation Button
  participant Handler as handleItemClick
  participant Modal as TinyModal
  User->>OperationButton: clicks button
  OperationButton->>Handler: call with itemData (row)
  Handler->>Handler: extract realName from itemData.itemData.name
  Handler->>Modal: show message with realName
  Handler->>Handler: toggle row.flag if applicable
  Modal-->>User: display confirmation
Loading

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

v81

Suggested reviewers

  • zzcr

Poem

🐰 A row of buttons, bright and spry,
I wiggle whiskers and give a try,
Icons ready, flags to toggle,
Clicks that sparkle, never boggle,
The grid hops lively—hip hooray!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding documentation for grid column operation type and operationConfig, plus removing unused cache code.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shen/add-grid-column-type

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shenjunjian shenjunjian added documentation 对文档的改进或补充 and removed bug Something isn't working labels Jun 12, 2026
gimmyhehe
gimmyhehe previously approved these changes Jun 12, 2026
@github-actions github-actions Bot added bug Something isn't working and removed documentation 对文档的改进或补充 labels Jun 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
examples/sites/demos/apis/grid.js (2)

2956-2978: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep the anchored column type docs in sync with the new prop contract.

This adds 'operation' to grid-column.type, but IColumnConfig later in the same file still documents type as 'index' | 'radio' | 'selection' only on Line 3283. That leaves the prop docs and every API entry that points at IColumnConfig out of sync.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/sites/demos/apis/grid.js` around lines 2956 - 2978, The docs add
'operation' to grid-column.type but IColumnConfig (and any API entries
referencing it) still list only 'index' | 'radio' | 'selection'; update
IColumnConfig's type union to include 'operation' and ensure any API/type
anchors that point to IColumnConfig (e.g., the grid-column.type docs and the API
entries using typeAnchorName: 'IColumnConfig' / typeAnchorName:
'IOperationConfig') are updated so the documented type union matches the new
prop contract across the file.

2980-2991: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix the width.pcDemo target.

operation-config already points at grid-operation-column#operation-column, and the registered demo lives under examples/sites/demos/pc/app/grid/webdoc/grid-operation-column.js. pcDemo: 'operation-column' will not resolve through the usual <section>#<demoId> lookup.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/sites/demos/apis/grid.js` around lines 2980 - 2991, The pc demo
target for the width prop is incorrect: update the width.pcDemo value (the
property on the object with name: 'width') to point at the actual registered
demo id instead of 'operation-column'; set it to the full section#demo id
'grid-operation-column#operation-column' so the normal <section>#<demoId> lookup
resolves correctly (this replaces the current pcDemo: 'operation-column' and
aligns with the existing operation-config / grid-operation-column registration).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/sites/demos/apis/grid.js`:
- Around line 4382-4394: The IOperationConfig type's buttons entry is incorrect:
make hidden and disabled optional and update the click signature to accept
(event, context) where context contains buttonConfig and the grid params;
specifically update IOperationConfig.buttons to be Array<{ name: string, icon:
Icon, click: (event: Event, ctx: { buttonConfig: any, params?: any }) => void,
hidden?: (row: any) => boolean, class?: string, disabled?: boolean | ((row: any)
=> boolean) }>, and ensure render and other props keep their existing names so
runtime callers match the type.

In `@packages/vue/src/grid/src/cell/src/cell.ts`:
- Around line 1036-1040: handleItemClick currently re-resolves actions by name
which breaks when labels duplicate; update it to prefer the full object payload
when available: if itemData.itemData (or itemData) already contains the button
config object use that directly instead of searching visibleButtons, otherwise
fall back to find by name; ensure you guard the result so you only call
buttonConfig.click(...) when buttonConfig is truthy and pass the same event and
params (preserving the existing window.event fallback).

---

Outside diff comments:
In `@examples/sites/demos/apis/grid.js`:
- Around line 2956-2978: The docs add 'operation' to grid-column.type but
IColumnConfig (and any API entries referencing it) still list only 'index' |
'radio' | 'selection'; update IColumnConfig's type union to include 'operation'
and ensure any API/type anchors that point to IColumnConfig (e.g., the
grid-column.type docs and the API entries using typeAnchorName: 'IColumnConfig'
/ typeAnchorName: 'IOperationConfig') are updated so the documented type union
matches the new prop contract across the file.
- Around line 2980-2991: The pc demo target for the width prop is incorrect:
update the width.pcDemo value (the property on the object with name: 'width') to
point at the actual registered demo id instead of 'operation-column'; set it to
the full section#demo id 'grid-operation-column#operation-column' so the normal
<section>#<demoId> lookup resolves correctly (this replaces the current pcDemo:
'operation-column' and aligns with the existing operation-config /
grid-operation-column registration).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0570da0c-50cd-4a21-aeaf-fcd3d34efce6

📥 Commits

Reviewing files that changed from the base of the PR and between 2b00c06 and 1393625.

📒 Files selected for processing (5)
  • examples/sites/demos/apis/grid.js
  • examples/sites/demos/pc/app/grid/operation-column/operation-column-composition-api.vue
  • examples/sites/demos/pc/app/grid/operation-column/operation-column.vue
  • examples/sites/demos/pc/app/grid/webdoc/grid-operation-column.js
  • packages/vue/src/grid/src/cell/src/cell.ts

Comment on lines +4382 to 4394
name: 'IOperationConfig',
type: 'type',
code: `
interface IOperationConfig {
// 操作列的按钮配置
buttons: Array<{name:string, icon:Icon, click:()=>void, hidden:(row)=> boolean, class?:string, disabled?:boolean| (row)=> boolean}>
// 最多显示按钮数,默认值为3
max?: number
// 自定义操作列渲染函数, 优先级高
render?: ({h, buttons, params}) => VNode
// 禁用时需要添加的class
disabledClass?:string
}`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

IOperationConfig.buttons does not match the runtime API.

The runtime accepts optional hidden/disabled flags and invokes click with (event, { buttonConfig, ...params }), but this type makes hidden mandatory and documents click: () => void. Users following this contract will implement the wrong handler shape.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/sites/demos/apis/grid.js` around lines 4382 - 4394, The
IOperationConfig type's buttons entry is incorrect: make hidden and disabled
optional and update the click signature to accept (event, context) where context
contains buttonConfig and the grid params; specifically update
IOperationConfig.buttons to be Array<{ name: string, icon: Icon, click: (event:
Event, ctx: { buttonConfig: any, params?: any }) => void, hidden?: (row: any) =>
boolean, class?: string, disabled?: boolean | ((row: any) => boolean) }>, and
ensure render and other props keep their existing names so runtime callers match
the type.

Comment on lines 1036 to 1040
const handleItemClick = (itemData) => {
// 兼容不同itemData数据类型
const realName = itemData?.name || itemData
// 兼容不同itemData数据类型, 第一段是兼容tiny的事件, 第二段是兼容 aurora design 的事件
const realName = itemData?.itemData?.name || itemData?.name || itemData
const buttonConfig = visibleButtons.find(({ name: buttonName }) => buttonName === realName)
buttonConfig.click(window.event || {}, { buttonConfig, ...params })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Do not resolve dropdown actions by label text.

DropdownItem now carries the full buttonConfig in itemData, but handleItemClick still re-finds the action by name. If two visible buttons share the same label, the first match wins and the wrong handler runs. Use the object payload when present, and guard the lookup before calling .click.

Suggested fix
     const handleItemClick = (itemData) => {
-      // 兼容不同itemData数据类型,  第一段是兼容tiny的事件, 第二段是兼容 aurora design 的事件
-      const realName = itemData?.itemData?.name || itemData?.name || itemData
-      const buttonConfig = visibleButtons.find(({ name: buttonName }) => buttonName === realName)
-      buttonConfig.click(window.event || {}, { buttonConfig, ...params })
+      // 兼容不同 itemData 数据类型,优先使用完整配置对象,避免按名称匹配误命中
+      const buttonConfig =
+        itemData?.itemData ||
+        itemData?.name && visibleButtons.find(({ name: buttonName }) => buttonName === itemData.name) ||
+        visibleButtons.find(({ name: buttonName }) => buttonName === itemData)
+
+      if (buttonConfig?.click) {
+        buttonConfig.click(window.event || {}, { buttonConfig, ...params })
+      }
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/vue/src/grid/src/cell/src/cell.ts` around lines 1036 - 1040,
handleItemClick currently re-resolves actions by name which breaks when labels
duplicate; update it to prefer the full object payload when available: if
itemData.itemData (or itemData) already contains the button config object use
that directly instead of searching visibleButtons, otherwise fall back to find
by name; ensure you guard the result so you only call buttonConfig.click(...)
when buttonConfig is truthy and pass the same event and params (preserving the
existing window.event fallback).

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants