Skip to content

Commit 644967d

Browse files
authored
feat(table): column SettingTitle 内容太长时显示省略&弹出 tooltip (#8070)
* feat(table/column-setting): column-title 内容太长时显示省略&弹出 tooltip * fix(table/column-setting): 挪 column-title_tooltip 至 Tree.titleRender 中 * style(table/column-setting): code format
1 parent 96d2658 commit 644967d

File tree

1 file changed

+22
-3
lines changed
  • packages/table/src/components/ColumnSetting

1 file changed

+22
-3
lines changed

packages/table/src/components/ColumnSetting/index.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ import {
66
} from '@ant-design/icons';
77
import { ProProvider, useIntl } from '@ant-design/pro-provider';
88
import { runFunction, useRefFunction } from '@ant-design/pro-utils';
9-
import type { TableColumnType } from 'antd';
10-
import { Checkbox, ConfigProvider, Popover, Space, Tooltip, Tree } from 'antd';
9+
import {
10+
Checkbox,
11+
ConfigProvider,
12+
Popover,
13+
Space,
14+
Tooltip,
15+
Tree,
16+
Typography,
17+
type TableColumnType,
18+
} from 'antd';
1119
import type { CheckboxChangeEvent } from 'antd/lib/checkbox';
1220
import type { DataNode } from 'antd/lib/tree';
1321
import classNames from 'classnames';
@@ -160,6 +168,7 @@ const CheckboxList: React.FC<{
160168
: config.disable?.checkbox,
161169
isLeaf: parentConfig ? true : undefined,
162170
};
171+
163172
if (children) {
164173
item.children = loopData(children, {
165174
...config,
@@ -260,12 +269,22 @@ const CheckboxList: React.FC<{
260269
titleRender={(_node) => {
261270
const node = { ..._node, children: undefined };
262271
if (!node.title) return null;
272+
const normalizedTitle = runFunction(node.title, node);
273+
const wrappedTitle = (
274+
<Typography.Text
275+
style={{ width: 80 }}
276+
ellipsis={{ tooltip: normalizedTitle }}
277+
>
278+
{normalizedTitle}
279+
</Typography.Text>
280+
);
281+
263282
return (
264283
<CheckboxListItem
265284
className={className}
266285
{...node}
267286
showListItemOption={showListItemOption}
268-
title={runFunction(node.title, node)}
287+
title={wrappedTitle}
269288
columnKey={node.key as string}
270289
/>
271290
);

0 commit comments

Comments
 (0)