Skip to content

Conversation

lijinke666
Copy link
Contributor

@lijinke666 lijinke666 commented May 9, 2020

需求场景

设置 columns 的 ellipsis 属性后, 会很贴心的在自动省略的单元格, hover后显示完整的数据, 因为添加了html的title属性

const columns = [
  {
    title: 'name',
    dataIndex: 'name',
    width: 100,
    ellipsis: true,
  }
]

但比较尴尬, 在我们的业务场景中, 用户觉得 初次 hover 后显示 title 有一定的延迟, 大概有 2 秒左右, 所以用 Tooltip 替代 title, 但这样会有重复的提示, 如图 所以需要一个开关来关闭默认的 title 属性

image

使用

 <Table columns={columns} data={data} showCellEllipsisHtmlTitle={false} />

codesandbox

@codecov
Copy link

codecov bot commented May 9, 2020

Codecov Report

Merging #474 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #474   +/-   ##
=======================================
  Coverage   99.70%   99.70%           
=======================================
  Files          23       23           
  Lines         669      670    +1     
  Branches      190      191    +1     
=======================================
+ Hits          667      668    +1     
  Misses          2        2           
Impacted Files Coverage Δ
src/Header/HeaderRow.tsx 100.00% <ø> (ø)
src/Cell/index.tsx 98.36% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f736e6...a89eb8e. Read the comment docs.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented May 9, 2020

This pull request introduces 1 alert when merging 9682806 into 8f736e6 - view on LGTM.com

new alerts:

  • 1 for Useless conditional

@afc163
Copy link
Member

afc163 commented May 9, 2020

改成这样的 API 吧。

ellipsis: {
  showTitle?: boolean;
}

@lijinke666
Copy link
Contributor Author

lijinke666 commented May 9, 2020

ellipsis: {
showTitle?: boolean;
}

可以的, 你的意思是 在 <Table /> 上改成这个api

<Table ellipsis={{ showTitle: false }}/>

还是基于 columns 的 ellipsis 字段?

const columns = [
  {
    title: 'name',
    dataIndex: 'name',
    width: 100,
    ellipsis: true, 
    // ellipsis: { showTitle: false }
  }
]

@lijinke666
Copy link
Contributor Author

似乎 基于 columns ellipsis 更合理一点, 你认为呢

@afc163
Copy link
Member

afc163 commented May 9, 2020

下面这个。

@lijinke666
Copy link
Contributor Author

@afc163 偏右大佬麻烦有空review下哈

@afc163 afc163 merged commit daf3b4e into react-component:master May 10, 2020
@afc163
Copy link
Member

afc163 commented May 10, 2020

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants