- 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
This commit is contained in:
Murilo Araujo 2019-02-20 21:41:09 -08:00 коммит произвёл Facebook Github Bot
Родитель 9c1c5a7455
Коммит 28f1648989
1 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -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 <a href='https://android.googlesource.com/platform/frameworks/base/+/jb-release/core/java/android/widget/TextView.java'>TextView.java</a>}
*/
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