Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextInput] Add numberOfLines and maximumNumberOfLines props on iOS and fix Android implementation #35703

Closed
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c9e11d5
android part
Szymon20000 Mar 8, 2023
e55eed8
ios changes
Szymon20000 Mar 8, 2023
cd78e0d
update types, configs
Szymon20000 Mar 8, 2023
34acc74
fix NativeTextComponent Props
Szymon20000 Mar 8, 2023
22d7189
fix fabric issue with newlines
Szymon20000 Mar 10, 2023
e5388e1
Apply suggestions from code review
Szymon20000 Mar 15, 2023
448a5eb
add example to rntester
Szymon20000 Mar 15, 2023
8080b34
Merge remote-tracking branch 'upstream/main' into @szymon/numner_of_l…
Szymon20000 Apr 20, 2023
b58d914
fix text component on android - (is was stipping off natest views)
Szymon20000 Apr 22, 2023
b29648d
apply suggestions
Szymon20000 May 16, 2023
036d5ad
Merge remote-tracking branch 'upstream/main' into @szymon/numner_of_l…
Szymon20000 May 16, 2023
24614c6
update rntester examples
Szymon20000 May 16, 2023
2551355
Merge branch 'main' into @szymon/numner_of_lines_rn
Szymon20000 May 29, 2023
e367bc0
Move LayoutMetrics and LayoutPrimitives from core to graphics folder …
sammy-SC May 29, 2023
f77567d
Revert D45904748: Move LayoutMetrics and LayoutPrimitives from core t…
May 29, 2023
4bfc7be
translation auto-update for i18n/fb4a.config.json on master
May 30, 2023
bac869c
Make RNTester use RCTAppDelegate (#37572)
cipolleschi May 30, 2023
cfb5701
Backporting a fix for hermesc on linux (#37596)
cipolleschi May 30, 2023
d5dfc99
Attempt at fixing crash when blurring image on iOS (#37614)
sammy-SC May 30, 2023
f7d9693
Fix Fabric issue with React-Core pod when Xcode project has multiple …
douglowder May 30, 2023
ef6fc1c
Remove `greet.yml` action (#37587)
Pranav-yadav May 30, 2023
39709bb
Add tests in CI not to break Hermes-Xcode integration (#37616)
cipolleschi May 30, 2023
c3e1c41
Use SurfaceRegistry globals whenever available (#37410)
javache May 30, 2023
5a90e0d
Merge remote-tracking ranch 'upstream/main' into @szymon/numner_of_l…
Szymon20000 Jun 14, 2023
908eeca
choose proper numberOfLines prop name based on native config
Szymon20000 Jun 15, 2023
bcb467d
Update packages/react-native/ReactAndroid/src/main/java/com/facebook/…
Szymon20000 Jul 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
**/main.js
**/staticBundle.js
docs/generatedComponentApiDocs.js
packages/react-native/flow/
packages/react-native/Libraries/Renderer/*
packages/react-native/Libraries/vendor/**/*
Comment on lines -4 to -6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this related to your change?

flow/
Libraries/Renderer/*
Libraries/vendor/**/*
Szymon20000 marked this conversation as resolved.
Show resolved Hide resolved
node_modules/
packages/*/node_modules
packages/react-native-codegen/lib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ export type NativeProps = $ReadOnly<{|
*/
numberOfLines?: ?Int32,

/**
* Sets the maximum number of lines for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
* @platform android
*/
maximumNumberOfLines?: ?Int32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we name this maxNumberOfLines instead of maximumNumberOfLines, for consistency with other TextInput props maxLength and maxFontSizeMultiplier?

React Native isn't totally consistent with this since ScrollView has a maximumZoomScale, but would be good to be consistent within the same component.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also cc @necolas who I saw had some comments around web prop naming. I can see that there isn't a direct equivalent to this on web, so the current naming here (augmenting the well-used RN prop) makes sense (unless there is work to actually remove the old ones).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe maxRows?
I will do my best to apply your suggested changes early next week.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just renamed it in InternalTextInput & flow & TS so that end user can pass maxNumberOfLines prop but on the native side we still use maximumNumberOfLines. Hope it's fine


/**
* When `false`, if there is a small amount of space available around a text input
* (e.g. landscape orientation on a phone), the OS may choose to have the user edit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ const RCTTextInputViewConfig = {
placeholder: true,
autoCorrect: true,
multiline: true,
numberOfLines: true,
maximumNumberOfLines: true,
textContentType: true,
maxLength: true,
autoCapitalize: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,6 @@ export interface TextInputAndroidProps {
*/
inlineImagePadding?: number | undefined;

/**
* Sets the number of lines for a TextInput.
* Use it with multiline set to true to be able to fill the lines.
*/
numberOfLines?: number | undefined;

/**
* Sets the return key to the label. Use it instead of `returnKeyType`.
* @platform android
Expand Down Expand Up @@ -654,11 +648,29 @@ export interface TextInputProps
*/
maxLength?: number | undefined;

/**
* Sets the maximum number of lines for a TextInput.
* Use it with multiline set to true to be able to fill the lines.
*/
maximumNumberOfLines?: number | undefined;

/**
* If true, the text input can be multiple lines. The default value is false.
*/
multiline?: boolean | undefined;

/**
* Sets the number of lines for a TextInput.
* Use it with multiline set to true to be able to fill the lines.
*/
numberOfLines?: number | undefined;

/**
* Sets the number of rows for a TextInput.
* Use it with multiline set to true to be able to fill the lines.
*/
rows?: number | undefined;

/**
* Callback that is called when the text input is blurred
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,26 +343,12 @@ type AndroidProps = $ReadOnly<{|
*/
inlineImagePadding?: ?number,

/**
* Sets the number of lines for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
* @platform android
*/
numberOfLines?: ?number,

/**
* Sets the return key to the label. Use it instead of `returnKeyType`.
* @platform android
*/
returnKeyLabel?: ?string,

/**
* Sets the number of rows for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
* @platform android
*/
rows?: ?number,

/**
* When `false`, it will prevent the soft keyboard from showing when the field is focused.
* Defaults to `true`.
Expand Down Expand Up @@ -632,6 +618,12 @@ export type Props = $ReadOnly<{|
*/
keyboardType?: ?KeyboardType,

/**
* Sets the maximum number of lines for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
*/
maximumNumberOfLines?: ?number,

/**
* Specifies largest possible scale a font can reach when `allowFontScaling` is enabled.
* Possible values:
Expand All @@ -653,6 +645,12 @@ export type Props = $ReadOnly<{|
*/
multiline?: ?boolean,

/**
* Sets the number of lines for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
*/
numberOfLines?: ?number,

/**
* Callback that is called when the text input is blurred.
*/
Expand Down Expand Up @@ -814,6 +812,12 @@ export type Props = $ReadOnly<{|
*/
returnKeyType?: ?ReturnKeyType,

/**
* Sets the number of rows for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
*/
rows?: ?number,

/**
* If `true`, the text input obscures the text entered so that sensitive text
* like passwords stay secure. The default value is `false`. Does not work with 'multiline={true}'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ type AndroidProps = $ReadOnly<{|
/**
* Sets the number of lines for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
* @platform android
*/
numberOfLines?: ?number,

Expand All @@ -400,10 +399,14 @@ type AndroidProps = $ReadOnly<{|
/**
* Sets the number of rows for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
* @platform android
*/
rows?: ?number,

/**
* Sets the maximum number of lines the TextInput can have.
*/
maximumNumberOfLines?: ?number,

/**
* When `false`, it will prevent the soft keyboard from showing when the field is focused.
* Defaults to `true`.
Expand Down Expand Up @@ -1066,6 +1069,8 @@ function InternalTextInput(props: Props): React.Node {
accessibilityState,
id,
tabIndex,
rows,
numberOfLines,
...otherProps
} = props;

Expand Down Expand Up @@ -1436,6 +1441,7 @@ function InternalTextInput(props: Props): React.Node {
focusable={tabIndex !== undefined ? !tabIndex : focusable}
mostRecentEventCount={mostRecentEventCount}
nativeID={id ?? props.nativeID}
numberOfLines={props.rows ?? props.numberOfLines}
onBlur={_onBlur}
onKeyPressSync={props.unstable_onKeyPressSync}
onChange={_onChange}
Expand Down
9 changes: 5 additions & 4 deletions packages/react-native/Libraries/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const Text: React.AbstractComponent<
pressRetentionOffset,
role,
suppressHighlighting,
numberOfLines,
...restProps
} = props;

Expand Down Expand Up @@ -192,12 +193,12 @@ const Text: React.AbstractComponent<
}
}

let numberOfLines = restProps.numberOfLines;
let numberOfLinesValue = numberOfLines;
if (numberOfLines != null && !(numberOfLines >= 0)) {
console.error(
`'numberOfLines' in <Text> must be a non-negative number, received: ${numberOfLines}. The value will be set to 0.`,
);
numberOfLines = 0;
numberOfLinesValue = 0;
}

const hasTextAncestor = useContext(TextAncestor);
Expand Down Expand Up @@ -241,7 +242,7 @@ const Text: React.AbstractComponent<
isHighlighted={isHighlighted}
isPressable={isPressable}
nativeID={id ?? nativeID}
numberOfLines={numberOfLines}
maximumNumberOfLines={numberOfLinesValue}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the old code passed this too, but I think this prop may always no-op in the VirtualText case. In this case, the text is being used like a "span" to describe a specific portion of text, instead of being applied to the outer text component.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too. Do you think it's better to remove it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

ref={forwardedRef}
selectable={_selectable}
selectionColor={selectionColor}
Expand All @@ -267,7 +268,7 @@ const Text: React.AbstractComponent<
ellipsizeMode={ellipsizeMode ?? 'tail'}
isHighlighted={isHighlighted}
nativeID={id ?? nativeID}
numberOfLines={numberOfLines}
maximumNumberOfLines={numberOfLinesValue}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. As a general question, why are we mapping numberOfLines to maximumNumberOfLines?
  2. When Meta is shipping the main branch of React Native, JS code may be shipped up to a week before new native code. This change would cause issues with that, since there would be a moment we are no longer sending numberOfLines, but are now sending a new prop which will not be handled until the native update.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in Fabric we are already mapping it on the native side as Text component it sets maximumNumberOfLines on textAttributes or paragraphAttributes. There were few native classes shared between TextInputComponent and Text Component and this remapping on the native side made it much cleaner. I can find exactly the example if you want but that seems to be reasonable :) .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we resolve #2 here? We need to ship this as:

  1. JS change goes out first
  2. Native change goes out a week later

So, we will want to split this change into separate ones for native and JS, where native changes are merged before the JS changes.

In general I would recommend having separate PRs for platforms/sections anyways. I know I personally put quicker to review changes higher up on my priority queue.

ref={forwardedRef}
selectable={_selectable}
selectionColor={selectionColor}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ @implementation RCTTextViewManager {

RCT_EXPORT_MODULE(RCTText)

RCT_REMAP_SHADOW_PROPERTY(numberOfLines, maximumNumberOfLines, NSInteger)
RCT_EXPORT_SHADOW_PROPERTY(maximumNumberOfLines, NSInteger)
RCT_REMAP_SHADOW_PROPERTY(ellipsizeMode, lineBreakMode, NSLineBreakMode)
RCT_REMAP_SHADOW_PROPERTY(adjustsFontSizeToFit, adjustsFontSizeToFit, BOOL)
RCT_REMAP_SHADOW_PROPERTY(minimumFontScale, minimumFontScale, CGFloat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#import <React/RCTMultilineTextInputView.h>
#import <React/RCTMultilineTextInputViewManager.h>
#import <React/RCTUITextView.h>
#import <React/RCTBaseTextInputShadowView.h>

@implementation RCTMultilineTextInputViewManager

Expand All @@ -17,8 +19,21 @@ - (UIView *)view
return [[RCTMultilineTextInputView alloc] initWithBridge:self.bridge];
}

- (RCTShadowView *)shadowView
{
RCTBaseTextInputShadowView *shadowView = (RCTBaseTextInputShadowView *)[super shadowView];

shadowView.maximumNumberOfLines = 0;
shadowView.exactNumberOfLines = 0;
Comment on lines +26 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we use a different value from 0 to mean "unset"? It does not seem correct to do nothing if this is explicitly set to zero (though I'm not sure why anyone would do that).

Same below

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that values was used on android in shadow nodes so I just copied it.
It's also used by UIKit https://developer.apple.com/documentation/uikit/nstextcontainer/1444531-maximumnumberoflines


return shadowView;
}

#pragma mark - Multiline <TextInput> (aka TextView) specific properties

RCT_REMAP_VIEW_PROPERTY(dataDetectorTypes, backedTextInputView.dataDetectorTypes, UIDataDetectorTypes)

RCT_EXPORT_SHADOW_PROPERTY(maximumNumberOfLines, NSInteger)
RCT_REMAP_SHADOW_PROPERTY(numberOfLines, exactNumberOfLines, NSInteger)

@end
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy, nullable) NSString *text;
@property (nonatomic, copy, nullable) NSString *placeholder;
@property (nonatomic, assign) NSInteger maximumNumberOfLines;
@property (nonatomic, assign) NSInteger exactNumberOfLines;
Comment on lines 18 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did numberOfLines previously act as maximum?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on fabric yes

@property (nonatomic, copy, nullable) RCTDirectEventBlock onContentSizeChange;

- (void)uiManagerWillPerformMounting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,22 @@ - (NSAttributedString *)measurableAttributedText

- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize
{
NSAttributedString *attributedText = [self measurableAttributedText];
NSMutableAttributedString *attributedText = [[self measurableAttributedText] mutableCopy];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, we never mutate the previous AttributedString, but may completely replace it with the filler line variant to do a different measurement. Could we then avoid the copy, and just use a different pointer if we want to operate on something different?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I remember we need to sometimes add characters otherwise the size is not computed properly.
For instance when we have multiple empty lines. We do it only for layout part and it's not visible on the screen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I think on iOS we only add newlines but still we need to modify the object.


/*
* The block below is responsible for setting the exact height of the view in lines
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a question for @sammy-SC, is this kosher with any sort of AttributedString layout caching we are doing? I.e. is there something we need to cache bust if layout behavior here varies based on more of the number of line props?

* Unfortunatelly, iOS doesn't export any easy way to do it. So we set maximumNumberOfLines
* prop and then add random lines at the front. However, they are only used for layout
* so they are not visible on the screen.
*/
if (self.exactNumberOfLines) {
NSMutableString *newLines = [NSMutableString stringWithCapacity:self.exactNumberOfLines];
for (NSUInteger i = 0UL; i < self.exactNumberOfLines; ++i) {
[newLines appendString:@"\n"];
}
[attributedText insertAttributedString:[[NSAttributedString alloc] initWithString:newLines attributes:self.textAttributes.effectiveTextAttributes] atIndex:0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the AttributedString still have all of the various text props that were set?

Text can have things like, different font size in different parts, etc. I'm not sure the most sane way to handle this prop in combination with various metrics.

E.g. we can have an outer TextInput that customizes font size, then a span on the first character which changes it to something else? Which do we pick (it seems like in the java case, we copy all the spans over the beginning of the text).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it actually works only when we use same style for the whole TextInput component. I think it makes sense. Let's imagine someone passes Text component as children to textInput and every line has different size. How should that behave? Which line height should we use for missing lines?

_maximumNumberOfLines = self.exactNumberOfLines;
}

if (!_textStorage) {
_textContainer = [NSTextContainer new];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ - (RCTShadowView *)shadowView
RCTBaseTextInputShadowView *shadowView = (RCTBaseTextInputShadowView *)[super shadowView];

shadowView.maximumNumberOfLines = 1;
shadowView.exactNumberOfLines = 0;

return shadowView;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/react-native/Libraries/Text/TextNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {type TextProps} from './TextProps';

type NativeTextProps = $ReadOnly<{
...TextProps,
maximumNumberOfLines?: ?number,
isHighlighted?: ?boolean,
selectionColor?: ?ProcessedColorValue,
onClick?: ?(event: PressEvent) => mixed,
Expand All @@ -31,7 +32,7 @@ const textViewConfig = {
validAttributes: {
isHighlighted: true,
isPressable: true,
numberOfLines: true,
maximumNumberOfLines: true,
ellipsizeMode: true,
allowFontScaling: true,
dynamicTypeRamp: true,
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native/ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,9 @@ dependencies {
androidTestImplementation("androidx.test:rules:${ANDROIDX_TEST_VERSION}")
androidTestImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")

api('com.parse.bolts:bolts-tasks:1.4.0')
api('com.parse.bolts:bolts-applinks:1.4.0')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad merge?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think someone broke RN Tester when I was updating that pr and this changes has fixed it. Will remove it!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. Looks like RNTester has been fixed since then.

// This compileOnly dependency is needed to be able to update the offline
// mirror from a non-linux machine, while still executing inside a Linux CI
// as we declare a dependency on aap2 @linux so we're sure the linux artifact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class ViewDefaults {

public static final float FONT_SIZE_SP = 14.0f;
public static final int LINE_HEIGHT = 0;
public static final int NUMBER_OF_LINES = Integer.MAX_VALUE;
public static final int NUMBER_OF_LINES = -1;
public static final int MAXIMUM_NUMBER_OF_LINES = Integer.MAX_VALUE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class ViewProps {
public static final String LETTER_SPACING = "letterSpacing";
public static final String NEEDS_OFFSCREEN_ALPHA_COMPOSITING = "needsOffscreenAlphaCompositing";
public static final String NUMBER_OF_LINES = "numberOfLines";
public static final String MAXIMUM_NUMBER_OF_LINES = "maximumNumberOfLines";
public static final String ELLIPSIZE_MODE = "ellipsizeMode";
public static final String ADJUSTS_FONT_SIZE_TO_FIT = "adjustsFontSizeToFit";
public static final String MINIMUM_FONT_SCALE = "minimumFontScale";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ protected Spannable spannedFromShadowNode(
protected boolean mIsAccessibilityLink = false;

protected int mNumberOfLines = UNSET;
protected int mMaxNumberOfLines = UNSET;
protected int mTextAlign = Gravity.NO_GRAVITY;
protected int mTextBreakStrategy =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY;
Expand Down Expand Up @@ -412,6 +413,12 @@ public void setNumberOfLines(int numberOfLines) {
markUpdated();
}

@ReactProp(name = ViewProps.MAXIMUM_NUMBER_OF_LINES, defaultInt = UNSET)
public void setMaxNumberOfLines(int numberOfLines) {
mMaxNumberOfLines = numberOfLines == 0 ? UNSET : numberOfLines;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why treat zero as unset?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was already the case before with numberOfLines. But seems to have sense. iOS NSTextContainer also uses it as the default value.

markUpdated();
}

@ReactProp(name = ViewProps.LINE_HEIGHT, defaultFloat = Float.NaN)
public void setLineHeight(float lineHeight) {
mTextAttributes.setLineHeight(lineHeight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void setAccessible(ReactTextView view, boolean accessible) {
}

// 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) {
@ReactProp(name = ViewProps.MAXIMUM_NUMBER_OF_LINES, defaultInt = ViewDefaults.MAXIMUM_NUMBER_OF_LINES)
public void setMaxNumberOfLines(ReactTextView view, int numberOfLines) {
Comment on lines +52 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, same question as earlier. Are we changing behavior of the existing prop? Seems like this removes the old one in favor of the new one (breaking change).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really as on the js side it's just mapped.
On Fabric we already use that new name and I need to make it consistent across arch and platforms.

view.setNumberOfLines(numberOfLines);
}

Expand Down
Loading