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 https://github.com/facebook/react-native/pull/18540 Differential Revision: D7396379 Pulled By: mdvacca fbshipit-source-id: 6c4b223731143c5081b3d12a3c740d1e375bd586
This commit is contained in:
parent
8b9b3f605e
commit
85e33aaf90
|
@ -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 abstract class ReactTextAnchorViewManager<T extends View, C extends React
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue