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 https://github.com/facebook/react-native/pull/9188 Differential Revision: D3697115 fbshipit-source-id: c1768ac22bab3c0e41a9df38b7314f3201512eb2
This commit is contained in:
parent
2bd1f627ea
commit
dba1ce46bf
|
@ -408,7 +408,7 @@ public class ReactTextShadowNode extends LayoutShadowNode {
|
|||
|
||||
@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 class ReactTextViewManager extends BaseViewManager<ReactTextView, ReactTe
|
|||
// 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue