Skip to content

Commit

Permalink
feat(table): column SettingTitle 内容太长时显示省略&弹出 tooltip (#8070)
Browse files Browse the repository at this point in the history
* feat(table/column-setting): column-title 内容太长时显示省略&弹出 tooltip

* fix(table/column-setting): 挪 column-title_tooltip 至 Tree.titleRender 中

* style(table/column-setting): code format
  • Loading branch information
xlboy authored Jan 17, 2024
1 parent 96d2658 commit 644967d
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/table/src/components/ColumnSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ import {
} from '@ant-design/icons';
import { ProProvider, useIntl } from '@ant-design/pro-provider';
import { runFunction, useRefFunction } from '@ant-design/pro-utils';
import type { TableColumnType } from 'antd';
import { Checkbox, ConfigProvider, Popover, Space, Tooltip, Tree } from 'antd';
import {
Checkbox,
ConfigProvider,
Popover,
Space,
Tooltip,
Tree,
Typography,
type TableColumnType,
} from 'antd';
import type { CheckboxChangeEvent } from 'antd/lib/checkbox';
import type { DataNode } from 'antd/lib/tree';
import classNames from 'classnames';
Expand Down Expand Up @@ -160,6 +168,7 @@ const CheckboxList: React.FC<{
: config.disable?.checkbox,
isLeaf: parentConfig ? true : undefined,
};

if (children) {
item.children = loopData(children, {
...config,
Expand Down Expand Up @@ -260,12 +269,22 @@ const CheckboxList: React.FC<{
titleRender={(_node) => {
const node = { ..._node, children: undefined };
if (!node.title) return null;
const normalizedTitle = runFunction(node.title, node);
const wrappedTitle = (
<Typography.Text
style={{ width: 80 }}
ellipsis={{ tooltip: normalizedTitle }}
>
{normalizedTitle}
</Typography.Text>
);

return (
<CheckboxListItem
className={className}
{...node}
showListItemOption={showListItemOption}
title={runFunction(node.title, node)}
title={wrappedTitle}
columnKey={node.key as string}
/>
);
Expand Down

0 comments on commit 644967d

Please sign in to comment.