[RN 0.48.2 TextInput] onSubmitEditing not called if blurOnSubmit set to false
See original GitHub issueIs this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
react-native -v
: 0.48.2node -v
: 8.4.0npm -v
: 4.6.1yarn --version
:
- Target Platform: iOS, Android
- Development Operating System: macOS Sierra 10.12.6
- Build tools:
react-native run-ios
react-native run-android
Steps to Reproduce
<TextInput
blurOnSubmit={false}
onSubmitEditing={() => alert('!!!')}
returnKeyType={'done'}
/>
- If I press the done button onSubmitEditing callback not called
Expected Behavior
onSubmitEditing
should be called for blurOnSubmit={false}
text inputs
Reproducible Demo
https://snack.expo.io/S1tMt619b but I don’t know how to turn on the last RN version there
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:20 (13 by maintainers)
Top Results From Across the Web
RN 0.48.2 TextInput onSubmitEditing blurOnSubmit={false}
RN 0.48.2 TextInput onSubmitEditing blurOnSubmit={false}. [RN 0.48.2 TextInput] onSubmitEditing not called if blurOnSubmit set to false. Open with Expo Go.
Read more >textinput text not submitting using onsubmitEditing using ...
you have to pass text from submit event to the function, <TextInput onSubmitEditing={(event) => this.onSubmit(event.nativeEvent.text)} />.
Read more >types/react-native/index.d.ts - UNPKG
187, * Adds a listener to be invoked when events of the specified type are ... 1193, * If `false`, TextInput always asks...
Read more >TextInput · React Native
If true , focuses the input on componentDidMount . The default value is false . Type, Required. bool, No. blurOnSubmit.
Read more >Focus on the Next TextInput when Next Keyboard Button is ...
Then we need to add 3 props to our first input returnKeyType , onSubmitEditing , and blurOnSubmit set to false. <TextInput placeholder="First Name" ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could someone weigh in on the desired behavior when tapping the submit button?
Currently (before the changes I’m making) we have on Android:
submit
event, blur, do not insert newlinesubmit
event, blurAnd on iOS we have (on master, not 0.48.2):
submit
event, blur, do not insert newlinesubmit
event, blursubmit
event, insert newlinesubmit
eventI modified the Android behavior so that it generates a submit event for the last case. And I reconciled the iOS behavior with that:
submit
event, blur, do not insert newlinesubmit
event, blursubmit
eventThe current documentation for
onBlurSubmit
supports the behavior of the first case. But the documentation foronSubmitEditing
says the submit event is “invalid” if multiline is set (a contradiction in the first case).Does this new behavior seem correct? Is there any reason to still dispatch the submit event in the third case, when a newline is also inserted?
@hblumberg Yes, Expo SDK 20 is based on RN 47. I will try to repro this on master.