Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typography.Paragraph 截取行数显示不正确 #19219

Closed
1 task
shijunwen opened this issue Oct 15, 2019 · 10 comments · Fixed by #31449
Closed
1 task

Typography.Paragraph 截取行数显示不正确 #19219

shijunwen opened this issue Oct 15, 2019 · 10 comments · Fixed by #31449
Assignees
Labels
🐛 Bug Ant Design Team had proved that this is a bug. help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request.

Comments

@shijunwen
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

访问官网https://ant.design/components/typography-cn/#components-typography-demo-ellipsis

What is expected?

ellipsis={{ rows: 3, expandable: true }} 设置属性是3行,浏览器显示3行

What is actually happening?

ellipsis={{ rows: 3, expandable: true }} 设置属性是3行,浏览器显示4行

Environment Info
antd 3.23.6
React react 16.10.02
System windows 10
Browser Google Chrome 版本 77.0.3865.90(正式版本) (32 位)

当浏览器放大,缩小到一定的分辨率时也会导致行数显示错误

@shijunwen
Copy link
Author

image

@zombieJ
Copy link
Member

zombieJ commented Oct 15, 2019

我这里无法复现,能截个 gif 缩放看一下吗?

@shijunwen
Copy link
Author

typography

@shijunwen
Copy link
Author

image
我本机分辨率如上图,官网显示的示例ellipsis={{ rows: 3, expandable: true }} 显示如下图
image

@zombieJ
Copy link
Member

zombieJ commented Oct 16, 2019

缩放产生的精度问题 😣

@zombieJ zombieJ added help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request. 🐛 Bug Ant Design Team had proved that this is a bug. labels Oct 16, 2019
@ant-design-bot
Copy link
Contributor

Hello @shijunwen. We totally like your proposal/feedback, welcome to send us Pull Request for it. Please send your Pull Request to proper branch (feature branch for new feature, master for bugfix and other changes), fill the [Pull Request Template] here, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. Appreciate it advance and we are looking forword to your contribution!

你好 @shijunwen, 我们完全同意你的提议/反馈,欢迎直接在此仓库 创建一个 Pull Request 来解决这个问题。请将 Pull Request 发到正确的分支(新特性发到 feature 分支,其他发到 master 分支),务必填写 Pull Request 内的预设模板,提供改动所需相应的 changelog、TypeScript 定义、测试用例、文档等,并确保 CI 通过,我们会尽快进行 Review,提前感谢和期待您的贡献!

giphy

@WangJM001
Copy link

typography/util.tsx这个字符串截取的算法是不是有点问题,当childNodes的第1个node不是text类型且长度超过限制时,就会显示空

@Lpmvb
Copy link

Lpmvb commented Dec 29, 2020

https://codesandbox.io/s/flamboyant-sammet-rhgrx?file=/src/App.tsx

在这个例子中看到的一个现象是在 chrome 上,line-height = Math.floor(font-size * line-height)

const lineHeight = pxToNumber(originStyle.lineHeight);

这里获取 line-height 时在 chrome 是不是应该采用 Math.floor

@loddit
Copy link

loddit commented Apr 7, 2021

我也遇到了一样的问题, 可以在 https://ant.design/components/typography/ 这里直接复现
(已经在我的 Linux Chroimum 和几个同事的 Mac Chrome 复现 ,但是需要浏览器不同的缩放级别)

image

看起来问题在于 https://github.com/ant-design/ant-design/blob/master/components/typography/util.tsx#L76
maxHeight 的计算,这样可以保证高度是足以渲染 rows 里定义的行数,但是这样计算很危险,和可能让也高度足以装下 rows + 1 行的内容。

@afc163
Copy link
Member

afc163 commented Jul 19, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Ant Design Team had proved that this is a bug. help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants