Skip to content

Commit

Permalink
- Fixed line not breaking when multiline set to true and keyboard typ…
Browse files Browse the repository at this point in the history
…e 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: #21884

Differential Revision: D14162701

Pulled By: cpojer

fbshipit-source-id: b7d3fc8c5a4444dcfd29ad74d515a8ae486c7ede
  • Loading branch information
Murilo Araujo authored and facebook-github-bot committed Feb 21, 2019
1 parent 9c1c5a7 commit 28f1648
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,14 @@ public void setInputType(int type) {
// 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
Expand Down

1 comment on commit 28f1648

@julianoabrs
Copy link

Choose a reason for hiding this comment

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

When will this be released in a new version?

Please sign in to comment.