diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/Libraries/Text/TextInput/Multiline/RCTUITextView.m index 9d38dd14bc50b9..0197e928ffce3b 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -51,6 +51,7 @@ - (instancetype)initWithFrame:(CGRect)frame self.textColor = [UIColor blackColor]; // This line actually removes 5pt (default value) left and right padding in UITextView. self.textContainer.lineFragmentPadding = 0; + self.textContainer.maximumNumberOfLines = 2; self.scrollsToTop = NO; self.scrollEnabled = YES; } diff --git a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m index fc59b088fe670c..d532a8930d72ce 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m @@ -44,6 +44,7 @@ @implementation RCTBaseTextInputViewManager RCT_REMAP_VIEW_PROPERTY(returnKeyType, backedTextInputView.returnKeyType, UIReturnKeyType) RCT_REMAP_VIEW_PROPERTY(selectionColor, backedTextInputView.tintColor, UIColor) RCT_REMAP_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType) +RCT_REMAP_VIEW_PROPERTY(numberOfLines, backedTextInputView.numberOfLines, NSInteger) RCT_REMAP_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL) RCT_REMAP_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButtonMode, UITextFieldViewMode) RCT_REMAP_VIEW_PROPERTY(scrollEnabled, backedTextInputView.scrollEnabled, BOOL) @@ -72,6 +73,7 @@ @implementation RCTBaseTextInputViewManager RCT_EXPORT_SHADOW_PROPERTY(text, NSString) RCT_EXPORT_SHADOW_PROPERTY(placeholder, NSString) RCT_EXPORT_SHADOW_PROPERTY(onContentSizeChange, RCTBubblingEventBlock) + RCT_CUSTOM_VIEW_PROPERTY(multiline, BOOL, UIView) { diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h b/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h index bbb56d26d9a418..f492cbc6d830c6 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h @@ -121,6 +121,8 @@ class TextInputTraits final { */ bool contextMenuHidden{false}; + std::optional numberOfLines{0}; + /* * iOS & Android * Default value: `true`. diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/propsConversions.h b/ReactCommon/react/renderer/components/textinput/iostextinput/propsConversions.h index 15dc0004596da0..25f9d721579f76 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/propsConversions.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/propsConversions.h @@ -69,6 +69,12 @@ static TextInputTraits convertRawProp( "spellCheck", sourceTraits.spellCheck, defaultTraits.spellCheck); + traits.numberOfLines = convertRawProp( + context, + rawProps, + "numberOfLines", + sourceTraits.numberOfLines, + defaultTraits.numberOfLines); traits.caretHidden = convertRawProp( context, rawProps,