From 49c9ccd3f8150c5478b502cd5ee158f44750a549 Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Thu, 25 Aug 2022 15:54:32 -0700 Subject: [PATCH] feat: Add rows prop to TextInput component (#34488) Summary: This adds the Android only `rows` prop to TextInput as requested on https://github.com/facebook/react-native/issues/34424 mapping the existing `numberOfLines` prop to `rows`. This PR also updates the TextInputExample.android on the RNTester in order to facilitate the manual QA of this. ## Changelog [Android] [Added] - Add rows prop to TextInput component Pull Request resolved: https://github.com/facebook/react-native/pull/34488 Test Plan: 1. On Android open the RNTester app and navigate to the TextInput page 2. Test the `TextInput` component through the `Fixed number of lines` section https://user-images.githubusercontent.com/11707729/186300173-7de79799-25b8-48af-99c0-8e3abeae334f.mov Reviewed By: christophpurrer Differential Revision: D38981953 Pulled By: cipolleschi fbshipit-source-id: d4d84b3c0dac7342ba9a65e2491928fbc61ff4f1 --- Libraries/Components/TextInput/TextInput.js | 8 ++++++++ .../examples/TextInput/TextInputExample.android.js | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 3f9f196db5dec2..8277898df9e6a0 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -452,6 +452,13 @@ type AndroidProps = $ReadOnly<{| */ 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`. @@ -1356,6 +1363,7 @@ function InternalTextInput(props: Props): React.Node { disableFullscreenUI={props.disableFullscreenUI} focusable={focusable} mostRecentEventCount={mostRecentEventCount} + numberOfLines={props.rows ?? props.numberOfLines} onBlur={_onBlur} onChange={_onChange} onFocus={_onFocus} diff --git a/packages/rn-tester/js/examples/TextInput/TextInputExample.android.js b/packages/rn-tester/js/examples/TextInput/TextInputExample.android.js index f372bbb77c58dc..2a4b1f704abc9c 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputExample.android.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputExample.android.js @@ -392,12 +392,22 @@ exports.examples = ([ + + );