Skip to content

feat(table): add tooltip props#9438

Merged
chenshuai2144 merged 3 commits intoant-design:masterfrom
zzjiaxiang:add-tooltip-props
Feb 9, 2026
Merged

feat(table): add tooltip props#9438
chenshuai2144 merged 3 commits intoant-design:masterfrom
zzjiaxiang:add-tooltip-props

Conversation

@zzjiaxiang
Copy link
Contributor

@zzjiaxiang zzjiaxiang commented Feb 7, 2026

透传 tooltip 的属性

close #9297

Summary by CodeRabbit

  • 新功能

    • 椭圆省略号现在支持更丰富的提示配置,截断文本可显示交互式工具提示以查看完整内容并增强可读性。
  • 改进

    • 优化了省略号的配置选项与行为(包括提示合并与复制文本处理),提供更灵活且一致的展示与交互体验。

- Updated the `ellipsis` property in various components to use the new `ProEllipsis` type for improved type safety and flexibility.
- Modified the `LabelIconTip`, `ProDescriptionsItemProps`, and `ProColumnType` to accommodate the new ellipsis structure, allowing for tooltip integration.
- Enhanced the `genCopyable` utility to better manage ellipsis behavior, including support for tooltip properties.
- Updated documentation to reflect these changes, ensuring clarity on the new ellipsis functionality.
…nction

- Adjusted the order of properties in the tooltip object within the genEllipsis function to ensure proper integration of the tooltip title with existing ellipsis properties.
- This change enhances the functionality of the genCopyable utility by maintaining the intended behavior of tooltip display.
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 7, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zzjiaxiang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在增强表格、描述列表等组件的 ellipsis(省略号)功能,允许开发者更细致地控制省略文本的工具提示行为。通过引入新的类型定义并修改相关工具函数,现在可以直接将 Ant Design 的 TooltipProps 传递给 ellipsis 属性,从而实现更丰富的工具提示定制,提升用户体验。

Highlights

  • 扩展 ellipsis 属性: 扩展了 ellipsis 属性,使其能够透传 Ant Design 的 TooltipProps,从而允许更细致地控制省略文本的工具提示行为。
  • 引入新类型定义: 引入了 ProEllipsisProEllipsisTooltip 类型,以支持更灵活的省略号工具提示配置。
  • 更新工具函数: 更新了 genEllipsis 工具函数,使其能够解析并合并 ellipsis 属性中包含的 TooltipProps
  • 文档更新: 更新了 Table 组件的文档,反映 ellipsis 属性的新类型定义,明确了对 TooltipProps 的支持。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • site/components/table/index.md
    • 更新了 ellipsis 属性的类型描述,增加了对 TooltipProps 的支持。
  • src/descriptions/index.tsx
    • 引入 ProEllipsis 类型。
    • 更新 ProDescriptionsItemPropsellipsis 属性的类型为 ProEllipsis
  • src/table/typing.ts
    • 引入 ProEllipsis 类型。
    • 更新 ProColumnTypeellipsis 属性的类型为 ProEllipsis
  • src/utils/components/LabelIconTip/index.tsx
    • 引入 ProEllipsis 类型。
    • 更新 LabelIconTip 组件中 ellipsis 属性的类型为 ProEllipsis
  • src/utils/genCopyable/index.tsx
    • 新增 ProEllipsisTooltipProEllipsis 类型定义。
    • 修改 getEllipsis 函数的返回类型为 ProEllipsisTooltip | boolean
    • 重构 genEllipsis 函数,使其能够解析并合并 ellipsis 属性中包含的 TooltipProps
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

将 ellipsis 的类型从简单布尔/{showTitle?: boolean} 扩展为可配置的 ProEllipsis(支持 tooltip 配置),并在 genEllipsis 中实现对 tooltip 属性合并与展示逻辑,相关类型在 utils 导出并在 table、descriptions、LabelIconTip 等处统一使用;文档同步更新说明。

Changes

Cohort / File(s) Summary
类型与实现(工具函数)
src/utils/genCopyable/index.tsx, src/utils/index.tsx
新增导出类型 ProEllipsisTooltipProEllipsis;扩展 genEllipsis 实现以支持对象形式的 ellipsis.tooltip(合并 tooltip 属性、基于 needTranText 控制 tooltip 包裹),并导出 ProEllipsis
类型声明(表格)
src/table/typing.ts
ProColumnType.ellipsis 的类型从原 ColumnType 的 ellipsis 替换为新 ProEllipsis
组件集成
src/descriptions/index.tsx, src/utils/components/LabelIconTip/index.tsx
将组件/项属性中的 ellipsis 类型改为 ProEllipsis,保持原有运行时按 truthiness 处理的行为但支持 tooltip 配置。
文档
site/components/table/index.md
更新列定义文档,将 ellipsis 类型示例改为包含 tooltip 配置的 ProEllipsis 说明。

Sequence Diagram(s)

sequenceDiagram
    participant Dev as 开发者/配置 columns
    participant TableComp as ProTable/Descriptions
    participant Gen as genEllipsis
    participant Tooltip as Tooltip 组件
    participant DOM as 渲染输出

    Dev->>TableComp: 提供 column.ellipsis (ProEllipsis 或 boolean)
    TableComp->>Gen: 传入文本与 ellipsis 配置 (needTranText 等)
    Gen->>Gen: 判断 ellipsis 与文本,合并 ellipsis.tooltip(若为对象)
    alt tooltip 应显示
        Gen->>Tooltip: 创建 Tooltip (合并后的 props)
        Tooltip->>DOM: 包裹并渲染带 tooltip 的内容
    else 不显示 tooltip
        Gen->>DOM: 直接返回被截断的 DOM 文本
    end
Loading

预估代码审查工作量

🎯 3 (中等) | ⏱️ ~20 分钟

步骤说明

此变更通过引入新的 ProEllipsis 类型并扩展相关模块,使省略号配置支持自定义工具提示属性。跨表格、描述和工具模块更新类型定义以实现一致的椭圆省略号处理。

变更

组件 / 文件 摘要
类型定义与导出
src/utils/genCopyable/index.tsx, src/utils/index.tsx
引入新公开类型 ProEllipsisTooltipProEllipsis,允许在省略号配置中指定 tooltipshowTitle 属性。优化 genEllipsis 函数逻辑以支持工具提示合并和文本规范化。
模块集成
src/table/typing.ts, src/descriptions/index.tsx, src/utils/components/LabelIconTip/index.tsx
统一更新 ellipsis 属性类型声明为新的 ProEllipsis 类型,跨多个组件保持一致的类型契约。
文档更新
site/components/table/index.md
更新列定义 API 表,反映 ellipsis 属性的新类型签名及工具提示支持。

诗歌

🐰 小兔来报喜,省略可设矫情,
tooltip 合并好,展示更分明,
配置一并通,类型也统一,
鼠标一悬停,提示暖洋洋 ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确反映了主要变更:在table组件中为ellipsis属性添加tooltip props支持。
Linked Issues check ✅ Passed PR实现了issue #9297的需求:通过ProEllipsis类型支持自定义ellipsis中的tooltip属性(如destroyTooltipOnHide)。
Out of Scope Changes check ✅ Passed 所有变更都在scope内,包括类型定义、imports更新和tooltip支持实现,均与主要目标相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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.

@dosubot dosubot bot added the table label Feb 7, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 PR 主要是为 ellipsis 属性增加了透传 Tooltip 属性的能力,这是一个很好的功能增强。代码实现上,核心逻辑在 genEllipsis 函数中,通过判断 ellipsis 属性的类型来合并 Tooltip 的 props。

我有两个反馈:

  1. ProEllipsis 的类型定义似乎有误,导致 API 结构比较奇怪。
  2. 文档中 ellipsis 属性的类型格式需要修正,以更清晰地展示其结构。

整体来说,除了这两个小问题,PR 的方向是正确的。

tooltip?: TooltipProps;
};

export type ProEllipsis = { ellipsis?: ProEllipsisTooltip } | boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

high

ProEllipsis 的类型定义似乎不正确。当前的定义 { ellipsis?: ProEllipsisTooltip } | boolean 会导致一个奇怪的 API 结构,例如 ellipsis={{ ellipsis: { tooltip: ... } }},这可能不是你的本意,并且会让使用者感到困惑。

getEllipsis 函数的实现来看,item.ellipsis 被期望为 ProEllipsisTooltip | boolean 类型。因此,ProEllipsis 类型应该直接是 ProEllipsisTooltipboolean 的联合类型。

Suggested change
export type ProEllipsis = { ellipsis?: ProEllipsisTooltip } | boolean;
export type ProEllipsis = ProEllipsisTooltip | boolean;

| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | ------ |
| title | 与 antd 中基本相同,但是支持通过传入一个方法 | `ReactNode \| ((config: ProColumnType<T>, type: ProTableTypes) => ReactNode)` | - |
| tooltip | 会在 title 之后展示一个 icon,hover 之后提示一些信息 | `string` | - |
| ellipsis | 是否自动缩略 | boolean \| showTitle?: boolean,tooltip: [TooltipProps](https://ant-design.antgroup.com/components/tooltip-cn#api) | - |
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

ellipsis 属性的类型在文档中的格式不太正确。为了更清晰地展示其结构,建议使用反引号包裹,并明确表示 tooltip 是对象的一部分。

建议修改为:
`boolean | { showTitle?: boolean; tooltip?: [TooltipProps](https://ant-design.antgroup.com/components/tooltip-cn#api) }`
这样更易读,也更准确地反映了 ellipsis 的类型。

Suggested change
| ellipsis | 是否自动缩略 | boolean \| showTitle?: boolean,tooltip: [TooltipProps](https://ant-design.antgroup.com/components/tooltip-cn#api) | - |
| ellipsis | 是否自动缩略 | `boolean | { showTitle?: boolean; tooltip?: [TooltipProps](https://ant-design.antgroup.com/components/tooltip-cn#api) }` | - |

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

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

⚠️ Outside diff range comments (1)
src/descriptions/index.tsx (1)

50-50: ⚠️ Potential issue | 🟡 Minor

JSDoc 注释与新类型不一致

第 50 行的 JSDoc 仍然描述旧的类型 {boolean | { showTitle?: boolean }},但 ellipsis 已更新为 ProEllipsis 类型(支持 tooltip 属性)。

📝 建议更新 JSDoc
- * `@property` {boolean | { showTitle?: boolean }} [ellipsis] - 是否展示省略号,如果是一个对象,可以设置鼠标悬浮时是否展示完整的内容
+ * `@property` {ProEllipsis} [ellipsis] - 是否展示省略号,如果是一个对象,可以设置 showTitle 和 tooltip 属性
🤖 Fix all issues with AI agents
In `@site/components/table/index.md`:
- Line 256: The table prop type for ellipsis is malformed; update the type
expression to a proper object form such as "{ showTitle?: boolean; tooltip?:
TooltipProps }" (referencing TooltipProps) so it conforms to TypeScript syntax
and mark the new tooltip sub-property with its available version (e.g., add an
"@since x.x.x" note next to tooltip in the description); ensure you include the
TooltipProps link text and keep showTitle optional as shown by "showTitle?:
boolean".
- Around line 252-282: Update the English table docs so the ellipsis prop's type
matches the Chinese version: locate the ellipsis row in the English markdown
(index.en-US.md) and change its Type column from "boolean" to "boolean | {
showTitle?: boolean; tooltip?: TooltipProps }" (and add a link/reference to
TooltipProps like the Chinese doc does), ensuring the default/description text
remains consistent with the Chinese entry; adjust formatting to match the
surrounding table syntax for the render of the ellipsis row.

In `@src/table/typing.ts`:
- Line 122: 修复类型嵌套:当前 ProEllipsis 定义为 `{ ellipsis?: ProEllipsisTooltip } |
boolean` 导致双重嵌套,与运行时和测试期望不符。将 ProEllipsis 改为直接的联合类型 `boolean | { showTitle?:
boolean; tooltip?: TooltipProps }`(去掉中间的 ProEllipsisTooltip 包装),并保持 `ellipsis?:
ProEllipsis` 的使用不变,确保能够接受像 `ellipsis: { showTitle: true }` 的写法并与 Ant Design 的
TooltipProps 对齐。

In `@src/utils/genCopyable/index.tsx`:
- Around line 23-28: The return type of getEllipsis is incorrect: it declares
ProEllipsisTooltip | boolean but returns item.ellipsis which is a ProEllipsis
(the wrapper type) — update the function signature to return ProEllipsis |
boolean (or the precise type that matches item.ellipsis) and adjust any
downstream usages if needed; ensure getEllipsis's parameter is typed (replace
any with the correct input type) so TypeScript will validate that getEllipsis
returns the declared ProEllipsis (or boolean) and stays consistent with the
fixed ProEllipsis and ProEllipsisTooltip types.
- Around line 6-11: The ProEllipsis type is incorrect and causes a double-nested
ellipsis shape; change the exported type from "export type ProEllipsis = {
ellipsis?: ProEllipsisTooltip } | boolean;" to "export type ProEllipsis =
ProEllipsisTooltip | boolean;" so that item.ellipsis matches the runtime shape
used in getEllipsis (which accesses item.ellipsis?.showTitle) and update any
references or imports expecting the old nested form accordingly.
- Around line 44-49: The early return in the needTranText branch returns a fixed
tooltip object and ignores user-specified ellipsis.tooltip options (e.g.
destroyTooltipOnHide); update the needTranText branch in genCopyable (the block
using needTranText, item?.tooltip and dom) to merge/forward
item.ellipsis?.tooltip (or item.tooltip per existing shape) into the returned
tooltip props so any custom tooltip attributes are preserved—i.e., build the
tooltip object by spreading the user tooltip options and then setting/overriding
the content wrapper (className/"pro-table-tooltip-text") so custom props like
destroyTooltipOnHide are passed through.
🧹 Nitpick comments (1)
src/utils/index.tsx (1)

58-58: 建议同时导出 ProEllipsisTooltip 类型

ProEllipsis 引用了 ProEllipsisTooltip,用户在做类型缩窄或单独使用 tooltip 配置时可能需要该类型。当前仅导出了 ProEllipsis

♻️ 建议补充导出
-import type { ProEllipsis } from './genCopyable';
+import type { ProEllipsis, ProEllipsisTooltip } from './genCopyable';
 export type {
   ProEllipsis,
+  ProEllipsisTooltip,
   ProFormInstanceType,

Based on learnings: "Applies to **/*index.{ts,tsx} : Export all public interface types for user convenience"

Also applies to: 137-138

@zzjiaxiang zzjiaxiang marked this pull request as draft February 7, 2026 17:12
- Refined the `ProEllipsis` type definition in the genCopyable utility to enhance type safety by allowing a direct use of `ProEllipsisTooltip` or a boolean value.
- This change simplifies the type structure, ensuring better integration and understanding of the ellipsis functionality across components.
@zzjiaxiang zzjiaxiang marked this pull request as ready for review February 8, 2026 15:26
@chenshuai2144 chenshuai2144 merged commit df6c52f into ant-design:master Feb 9, 2026
7 of 9 checks passed
@zzjiaxiang zzjiaxiang deleted the add-tooltip-props branch February 9, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎖️ featrue size:L This PR changes 100-499 lines, ignoring generated files. table

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🧐[问题] ProTable的columns配置中ellipsis支持自定义设置tooltip属性吗?

2 participants