From 28f16489896d825cfd657f54d2131598784b7adf Mon Sep 17 00:00:00 2001 From: Murilo Araujo Date: Wed, 20 Feb 2019 21:41:09 -0800 Subject: [PATCH] - Fixed line not breaking when multiline set to true and keyboard type set to numeric (or other numeric type) (#21884) Summary: Native Android sets the EditText widget to multiline only if the InputType flags are set to Text (or its variants like textEmailAddress) and Multiline, which causes the React Native TextInput to not break the line when set to multiline={true} and keyboardType={'numeric'} as it only have the flags Multiline and Number set. This fix forces the widget to enable multiline, by calling setSingleLine(false) everytime a state change needs to be commited and the multiline prop is set to true. Pull Request resolved: https://github.com/facebook/react-native/pull/21884 Differential Revision: D14162701 Pulled By: cpojer fbshipit-source-id: b7d3fc8c5a4444dcfd29ad74d515a8ae486c7ede --- .../com/facebook/react/views/textinput/ReactEditText.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index e8d24d7ea73..74910dad323 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -331,6 +331,14 @@ public class ReactEditText extends EditText { // Input type password defaults to monospace font, so we need to re-apply the font super.setTypeface(tf); + /** + * If set forces multiline on input, because of a restriction on Android source that enables multiline only for inputs of type Text and Multiline on method {@link android.widget.TextView#isMultilineInputType(int)}} + * Source: {@Link TextView.java} + */ + if (isMultiline()) { + setSingleLine(false); + } + // We override the KeyListener so that all keys on the soft input keyboard as well as hardware // keyboards work. Some KeyListeners like DigitsKeyListener will display the keyboard but not // accept all input from it