-
Notifications
You must be signed in to change notification settings - Fork 201
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
fix: render maxLines text correctly after render twice #3089
base: next
Are you sure you want to change the base?
Conversation
你好 @Alexzjt,非常感谢你的贡献. Hello, @Alexzjt, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes. |
WalkthroughThis PR addresses a bug related to rendering text with a maximum number of lines ( Changes
|
@@ -856,7 +856,7 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group { | |||
|
|||
const maxLines = Math.max( | |||
1, | |||
Math.floor((displayHeight - padding) / lineHeight), | |||
Math.round((displayHeight - padding) / lineHeight), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from Math.floor
to Math.round
in the calculation of maxLines
may affect the rendering behavior. Ensure that this change does not introduce any unintended side effects, especially in edge cases where the line height and display height are close to each other.
@@ -856,7 +856,7 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group { | |||
|
|||
const maxLines = Math.max( | |||
1, | |||
Math.floor((displayHeight - padding) / lineHeight), | |||
Math.round((displayHeight - padding) / lineHeight), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题根因分析
- 数值截断逻辑矛盾
计算逻辑:(displayHeight - padding) / lineHeight = (61 - 16) / 16 = 2.8125 - 条件判断逻辑缺陷
isCustomHeight 触发条件:只有当 isCustomHeight = true 时才会执行计算,但代码中该参数默认值为 false,在二次渲染时外部传入 true,导致逻辑分歧。
👀 PR includes
✨ Feature
🎨 Enhance
🐛 Bugfix
🔧 Chore
📝 Description
🖼️ Screenshot
🔗 Related issue link
#3087
🔍 Self-Check before the merge