Skip to content

Commit 8cd9b76

Browse files
Take Text ellipsizeMode from the measured paragraph attributes on Android (#58865)
Summary: Pull Request resolved: #58865 On Android, `ReactTextView` measured text with the paragraph attributes from its state, but drew the ellipsis from a separate `ellipsizeMode` view prop that starts as `tail`. The paragraph attributes default `ellipsizeMode` to `clip`. When a view is created with props that omit values equal to their defaults, an explicit `ellipsizeMode="clip"` never reached the view prop, so text with `numberOfLines` was truncated with an ellipsis instead of being clipped. `ReactTextView` now takes the ellipsis from the same paragraph attributes it is measured with, like `minimumFontSize` and `textBreakStrategy`, so a single source of truth decides it, as on iOS. Changelog: [Android][Fixed] - Fix `ellipsizeMode="clip"` being ignored on newly created `Text` Reviewed By: christophpurrer Differential Revision: D123029564 fbshipit-source-id: 9f587f172d7586b3b747f5113a8e6f94d0ceeeb4
1 parent 98d6795 commit 8cd9b76

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.kt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ public constructor(
178178
else Float.NaN
179179
view.setMinimumFontScale(minimumFontScale)
180180

181+
view.setEllipsizeLocation(
182+
TextAttributeProps.getEllipsizeMode(
183+
paragraphAttributes.getString(TextLayoutManager.PA_KEY_ELLIPSIZE_MODE),
184+
),
185+
)
186+
view.updateView()
187+
181188
// Clear any stale PreparedLayout from a previous update
182189
view.setPreparedLayout(null)
183190

0 commit comments

Comments
 (0)