Skip to content

Commit

Permalink
Android: Setting numberOfLines to 0 behaves differently than on iOS.
Browse files Browse the repository at this point in the history
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
Mani Ghasemlou authored and Facebook Github Bot 7 committed Aug 10, 2016
1 parent 2bd1f62 commit dba1ce4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit dba1ce4

Please sign in to comment.