From c0cd6771657d538b75856d7094a51921ff6355ec Mon Sep 17 00:00:00 2001 From: Rylan Date: Wed, 3 Dec 2025 15:05:03 +0800 Subject: [PATCH 1/3] fix(Typography): `ellipsis` unexpectedly splits a word across two lines --- .../typography/ellipsis/Truncate.tsx | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/components/typography/ellipsis/Truncate.tsx b/packages/components/typography/ellipsis/Truncate.tsx index d5e3487d63..0b31cdbb29 100644 --- a/packages/components/typography/ellipsis/Truncate.tsx +++ b/packages/components/typography/ellipsis/Truncate.tsx @@ -228,6 +228,19 @@ export default class Truncate extends React.Component text.replace(/\s+$/, ''); + breakAtWordBoundary = (text: string) => { + // Try to break at word boundary to avoid splitting words + // Look backwards for a space or punctuation + const wordBoundaryMatch = text.match(/^(.*[\s\-,;.!?])/); + if (wordBoundaryMatch) { + const [, boundaryText] = wordBoundaryMatch; + if (boundaryText.trim().length > 0) { + return boundaryText; + } + } + return text; + }; + createMarkup = (str: string) => ( ); @@ -296,6 +309,7 @@ export default class Truncate extends React.Component Date: Wed, 3 Dec 2025 15:19:23 +0800 Subject: [PATCH 2/3] chore: update CHANGELOG.md --- packages/tdesign-react/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/tdesign-react/CHANGELOG.md b/packages/tdesign-react/CHANGELOG.md index f0ad6bc13c..5847ff858d 100644 --- a/packages/tdesign-react/CHANGELOG.md +++ b/packages/tdesign-react/CHANGELOG.md @@ -577,8 +577,8 @@ spline: explain ## 🌈 1.9.3 `2024-10-31` ### 🐞 Bug Fixes -- `Select`: 修复`valueDisplay`下的`onClose`回调问题 @uyarn ([#3154](https://github.com/Tencent/tdesign-react/pull/3154)) -- `Typography`: 修复 `Typography` 的`Ellipsis` 功能在中文下的问题 @HaixingOoO ([#3158](https://github.com/Tencent/tdesign-react/pull/3158)) +- `Select`: 修复 `valueDisplay` 下的 `onClose` 回调问题 @uyarn ([#3154](https://github.com/Tencent/tdesign-react/pull/3154)) +- `Typography`: 修复 `ellipsis` 功能在中文下的问题 @HaixingOoO ([#3158](https://github.com/Tencent/tdesign-react/pull/3158)) - `Form`: 修复 `FormList` 或 `FormItem` 数据中的 `getFieldsValue` 问题 @HaixingOoO ([#3149](https://github.com/Tencent/tdesign-react/pull/3149)) - `Form`: 修复动态渲染表单无法使用 `setFieldsValue` 预设数据的问题 @l123wx ([#3145](https://github.com/Tencent/tdesign-react/pull/3145)) - `lib`: 修复`1.9.2`升级依赖改动导致`lib`错误携带`style`导致在`next`下不可用的异常 @honkinglin ([#3165](https://github.com/Tencent/tdesign-react/pull/3165)) From f21c9b5b2cf39f250df0791ceb48b484830b37dd Mon Sep 17 00:00:00 2001 From: Rylan Date: Wed, 3 Dec 2025 16:17:27 +0800 Subject: [PATCH 3/3] chore: update comments Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/components/typography/ellipsis/Truncate.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/typography/ellipsis/Truncate.tsx b/packages/components/typography/ellipsis/Truncate.tsx index 0b31cdbb29..e7c14df953 100644 --- a/packages/components/typography/ellipsis/Truncate.tsx +++ b/packages/components/typography/ellipsis/Truncate.tsx @@ -230,7 +230,7 @@ export default class Truncate extends React.Component { // Try to break at word boundary to avoid splitting words - // Look backwards for a space or punctuation + // Find the last word boundary (space or punctuation) to break at const wordBoundaryMatch = text.match(/^(.*[\s\-,;.!?])/); if (wordBoundaryMatch) { const [, boundaryText] = wordBoundaryMatch;