Skip to content

Commit

Permalink
Prevents android crash due to unsupported ellipsize mode
Browse files Browse the repository at this point in the history
Fixes facebook#18474

Applies the default behavior if the ellipsize mode is set
to "clip", since it's only supported by IOS
  • Loading branch information
t4deu committed Mar 24, 2018
1 parent 1acef45 commit 774ba4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RNTester/js/TextExample.android.js
Expand Up @@ -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}>
Because clip is only supported on IOS this text should be truncated with dots in the end.
</Text>
</RNTesterBlock>
<RNTesterBlock title="Include Font Padding">
<View style={{flexDirection: 'row', justifyContent: 'space-around', marginBottom: 10}}>
Expand Down
Expand Up @@ -46,7 +46,9 @@ public void setNumberOfLines(ReactTextView view, int numberOfLines) {

@ReactProp(name = ViewProps.ELLIPSIZE_MODE)
public void setEllipsizeMode(ReactTextView view, @Nullable String ellipsizeMode) {
if (ellipsizeMode == null || ellipsizeMode.equals("tail")) {
if (ellipsizeMode == null
|| ellipsizeMode.equals("tail")
|| ellipsizeMode.equals("clip")) {
view.setEllipsizeLocation(TextUtils.TruncateAt.END);
} else if (ellipsizeMode.equals("head")) {
view.setEllipsizeLocation(TextUtils.TruncateAt.START);
Expand Down

0 comments on commit 774ba4f

Please sign in to comment.