Permalink
Browse files

Android: Setting numberOfLines to 0 behaves differently than on iOS.

Summary:
**Motivation**

For the `Text` component, if `numberOfLines` is set to `0`, the behavior on iOS is such that there is no limit.

On Android, the behavior is such that `numberOfLines={0}` will not render the `Text` component.

Since we want behavior to be the same across platforms, this change will make sure Android behaves the same as iOS.

**Test Plan**

Create a `Text` component specifying `numberOfLines={0}` on an Android project.

Expected:
- `Text` component displays, with no limit to number of lines.

Result:
- `Text` component does not appear at all.
Closes #9188

Differential Revision: D3697115

fbshipit-source-id: c1768ac22bab3c0e41a9df38b7314f3201512eb2
  • Loading branch information...
1 parent 2bd1f62 commit dba1ce46bfeda76c0eacb544f16044dd218b55e3 Mani Ghasemlou committed with Facebook Github Bot 7 Aug 10, 2016
@@ -408,7 +408,7 @@ public void setText(@Nullable String text) {
@ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = UNSET)
public void setNumberOfLines(int numberOfLines) {
- mNumberOfLines = numberOfLines;
+ mNumberOfLines = numberOfLines == 0 ? UNSET : numberOfLines;
markUpdated();
}
@@ -51,7 +51,7 @@ public ReactTextView createViewInstance(ThemedReactContext context) {
// maxLines can only be set in master view (block), doesn't really make sense to set in a span
@ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = ViewDefaults.NUMBER_OF_LINES)
public void setNumberOfLines(ReactTextView view, int numberOfLines) {
- view.setMaxLines(numberOfLines);
+ view.setMaxLines(numberOfLines == 0 ? ViewDefaults.NUMBER_OF_LINES : numberOfLines);
view.setEllipsize(TextUtils.TruncateAt.END);
}

0 comments on commit dba1ce4

Please sign in to comment.