Permalink
Browse files

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
  • Loading branch information...
t4deu authored and facebook-github-bot committed Mar 26, 2018
1 parent 8b9b3f6 commit 85e33aaf908996e99220bff4a2bdbbdf7c0d12b0
@@ -453,6 +453,9 @@ class TextExample extends React.Component<{}> {
<Text ellipsizeMode="head" numberOfLines={1}>
This very long text should be truncated with dots in the beginning.
</Text>
<Text ellipsizeMode="clip" numberOfLines={1}>
This very long text should be clipped and this will not be visible.
</Text>
</RNTesterBlock>
<RNTesterBlock title="Include Font Padding">
<View style={{flexDirection: 'row', justifyContent: 'space-around', marginBottom: 10}}>
@@ -52,6 +52,8 @@ public void setEllipsizeMode(ReactTextView view, @Nullable String ellipsizeMode)
view.setEllipsizeLocation(TextUtils.TruncateAt.START);
} else if (ellipsizeMode.equals("middle")) {
view.setEllipsizeLocation(TextUtils.TruncateAt.MIDDLE);
} else if (ellipsizeMode.equals("clip")) {
view.setEllipsizeLocation(null);
} else {
throw new JSApplicationIllegalArgumentException("Invalid ellipsizeMode: " + ellipsizeMode);
}

0 comments on commit 85e33aa

Please sign in to comment.