Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANDROID][BUGFIX][TextInput] - Fixed line not breaking when multiline set to true and keyboard type set to numeric (or other numeric type) #21884

Closed
wants to merge 3 commits into from

Conversation

Muritavo
Copy link

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.

Test Plan:

This bug only occurs on Android devices

  1. Create a TextInput component with multiline set to true and keyboardType set to 'numeric' or 'phone-pad' or any numeric type.
<TextInput
   keyboardType={"numeric"}
   numberOfLines={6}
   multiline={true}/>
  1. Input some text until it reaches the end of the component

  2. See as you keep input more data, the line doesn't break

The test plan can be reproduced HERE

Release Notes:

[ANDROID] [BUGFIX] [TextInput] - Fixed line not breaking when multiline set to true and keyboard type set to numeric (or other numeric type)

@react-native-bot react-native-bot added Platform: Android Android applications. Component: TextInput Related to the TextInput component. 🔶Components labels Oct 22, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 22, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@Muritavo Muritavo closed this Nov 7, 2018
@Muritavo Muritavo reopened this Nov 8, 2018
Copy link
Contributor

@matthargett matthargett left a comment

Choose a reason for hiding this comment

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

Can you add an e2e test for this?

@Muritavo
Copy link
Author

Sure, this week I'm a little busy with the exams coming, so I'll only be able to look into this after wednesday

@RSNara
Copy link
Contributor

RSNara commented Jan 16, 2019

@Muritavo, thanks for the PR!

One question: Are you sure that this is sufficient to fix the bug? If you replace numberOfLines with a really long placeholder, we still can't get multiline numeric <TextInput/>s. 🤔

<TextInput
  multiline={true}
  keyboardType="numeric"
  style={styles.input}
  placeholder="some really really really really really really long text"
/>

Do you think that's a different problem? I'm asking because maybe there's a better solution that fixes both cases.

@mmamaniwolox
Copy link

It would be awesome to have this working, great job @Muritavo . I hope this is merged soon :P Need it so bad haha

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Feb 21, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

Murilo Araujo merged commit 28f1648 into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Feb 21, 2019
@react-native-bot react-native-bot added the Merged This PR has been merged. label Feb 21, 2019
mbardauskas pushed a commit to mbardauskas/react-native that referenced this pull request Feb 21, 2019
…e set to numeric (or other numeric type) (facebook#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: facebook#21884

Differential Revision: D14162701

Pulled By: cpojer

fbshipit-source-id: b7d3fc8c5a4444dcfd29ad74d515a8ae486c7ede
@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: TextInput Related to the TextInput component. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants