Skip to content

Commit 85e33aa

Browse files
t4deufacebook-github-bot
authored andcommitted
Prevents android crash due to unsupported ellipsize mode
Summary: Fixes #18474 This allows use clip as ellipsize mode for truncated text on android Added a test to RNTester, so it can be tested from there: 1. Run RNTester project 2. Navigate to `<Text>` tests 3. Scroll down to "Ellipsize mode" examples 4. Check the default behavior being applied when the value is set to "clip" <!-- Required. Help reviewers and the release process by writing your own release notes. See below for an example. --> [ANDROID] [BUGFIX] [Text] - Prevents android crash due to unsupported "clip" ellipsize mode <!-- **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [ {Component} ] [ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes #18540 Differential Revision: D7396379 Pulled By: mdvacca fbshipit-source-id: 6c4b223731143c5081b3d12a3c740d1e375bd586
1 parent 8b9b3f6 commit 85e33aa

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

RNTester/js/TextExample.android.js

+3
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ class TextExample extends React.Component<{}> {
453453
<Text ellipsizeMode="head" numberOfLines={1}>
454454
This very long text should be truncated with dots in the beginning.
455455
</Text>
456+
<Text ellipsizeMode="clip" numberOfLines={1}>
457+
This very long text should be clipped and this will not be visible.
458+
</Text>
456459
</RNTesterBlock>
457460
<RNTesterBlock title="Include Font Padding">
458461
<View style={{flexDirection: 'row', justifyContent: 'space-around', marginBottom: 10}}>

ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public void setEllipsizeMode(ReactTextView view, @Nullable String ellipsizeMode)
5252
view.setEllipsizeLocation(TextUtils.TruncateAt.START);
5353
} else if (ellipsizeMode.equals("middle")) {
5454
view.setEllipsizeLocation(TextUtils.TruncateAt.MIDDLE);
55+
} else if (ellipsizeMode.equals("clip")) {
56+
view.setEllipsizeLocation(null);
5557
} else {
5658
throw new JSApplicationIllegalArgumentException("Invalid ellipsizeMode: " + ellipsizeMode);
5759
}

0 commit comments

Comments
 (0)