-
Notifications
You must be signed in to change notification settings - Fork 360
fix(Typography): ellipsis unexpectedly splits a word across two lines
#3997
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
base: develop
Are you sure you want to change the base?
Conversation
commit: |
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.
Pull request overview
This PR fixes a bug in the Typography component's ellipsis feature where English words were unexpectedly split across two lines when truncated. The fix introduces intelligent word boundary detection to break text at appropriate points (spaces, hyphens, punctuation) rather than mid-word.
Key Changes:
- Added
breakAtWordBoundary()method to detect and break at word boundaries - Applied word boundary logic to both last-line truncation and multi-line truncation scenarios
- Minor formatting improvements to existing CHANGELOG entries
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/components/typography/ellipsis/Truncate.tsx | Adds breakAtWordBoundary() method and integrates it into the text truncation algorithm to prevent words from being split across lines |
| packages/tdesign-react/CHANGELOG.md | Formatting improvements to existing entries (spacing around backticks), but missing a new entry for this PR |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

🤔 这个 PR 的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
https://tdesign.tencent.com/react/components/typography#可省略

📝 更新日志
fix(Typography): 修复开启
ellipsis时,将一个完整英文单词切割放在两行的问题本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单