Skip to content

Commit

Permalink
fix(table): remove unnecessary tooltip (#1907)
Browse files Browse the repository at this point in the history
* feat(table): remove unnecessary tooltip

* feat(table): update snapshot

* feat(table): update ellipsis

* feat(table): delete genEllipsis
  • Loading branch information
beichensky committed Feb 23, 2021
1 parent 123ee31 commit 932a769
Show file tree
Hide file tree
Showing 5 changed files with 2,703 additions and 2,524 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/rebase.yml
Expand Up @@ -8,10 +8,10 @@ jobs:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 4 additions & 17 deletions packages/table/src/utils.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import type { TablePaginationConfig, TableColumnType } from 'antd';
import { Space, Tooltip, Form, Typography } from 'antd';
import { Space, Form, Typography } from 'antd';

import type {
ProFieldValueType,
Expand Down Expand Up @@ -41,23 +41,12 @@ export const genColumnKey = (key?: React.ReactText | undefined, index?: number):
};

/**
* 生成 Ellipsis 的 tooltip
* 生成 Copyable 或 Ellipsis 的 dom
*
* @param dom
* @param item
* @param text
*/
export const genEllipsis = (dom: React.ReactNode, item: ProColumns<any>, text: string) => {
if (!item.ellipsis) {
return dom;
}
return (
<Tooltip title={text}>
<span>{dom}</span>
</Tooltip>
);
};

export const genCopyable = (dom: React.ReactNode, item: ProColumns<any>, text: string) => {
if (item.copyable || item.ellipsis) {
return (
Expand All @@ -76,7 +65,7 @@ export const genCopyable = (dom: React.ReactNode, item: ProColumns<any>, text: s
}
: undefined
}
ellipsis={item.ellipsis}
ellipsis={item.ellipsis && text ? { tooltip: text } : false}
>
{dom}
</Typography.Text>
Expand Down Expand Up @@ -296,9 +285,7 @@ export function columnRender<T>({
});

const dom: React.ReactNode =
mode === 'edit'
? textDom
: genEllipsis(genCopyable(textDom, columnProps, renderTextStr), columnProps, renderTextStr);
mode === 'edit' ? textDom : genCopyable(textDom, columnProps, renderTextStr);

/** 如果是编辑模式,并且 renderFormItem 存在直接走 renderFormItem */
if (mode === 'edit') {
Expand Down

0 comments on commit 932a769

Please sign in to comment.