[Android] onSubmitEditing is called twice when keyboard is dismissed in android
See original GitHub issueI want to get current text from TextInput when keyboard is dismissed by pressing search button. In order to get the text, I use onSubmitEditing but it is called twice only if I set returnKeyType to ‘search’. Here is a code snippet.
render() {
return (
<View style={{flex:1, justifyContent:'center'}}>
<TextInput
style={{alignSelf:'stretch'}}
onChangeText={(searchInput) => this.setState({ searchInput }) }
placeholder='Search'
returnKeyType='search'
onFocus={() => console.log('onFocus')}
onBlur={() => console.log('onBlur')}
onChange={(event) => console.log('onChange text: ' + event.nativeEvent.text)}
onEndEditing={(event) => console.log('onEndEditing text: ' + event.nativeEvent.text)}
onSubmitEditing={(event) => console.log('onSubmitEditing text: ' + event.nativeEvent.text)}
/>
</View>
);
}
and no one answer the question in stackoverflow http://stackoverflow.com/questions/38710253/onsubmitediting-is-called-twice-when-keyboard-is-dismissed
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:17 (4 by maintainers)
Top Results From Across the Web
onSubmitEditing is called twice when keyboard is dismissed
I want to get current text from TextInput when keyboard is dismissed by pressing search button. In order to get the text, I...
Read more >Focus on the Next TextInput when Next Keyboard Button is ...
The onSubmitEditing is called when that button is pressed. This will then trigger focus on the text input that we have a ref...
Read more >Hardware Backbutton In react native android not working ...
[Solved]-Hardware Backbutton In react native android not working-React Native ... onSubmitEditing is called twice when keyboard is dismissed · react native ...
Read more >TextInput - React Native
A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >React Native Hide Dismiss Keyboard on Touch Outside ...
React native Keyboard.dismiss() method is used to hide the keyboard. React Native Hide Dismiss Keyboard on Touch Outside Android iOS ...
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
Confirming that this occurs on Android 6.0.1, both simulator and device. However it only happens when using certain
returnKeyType
values. IfreturnKeyType
is omitted, the event only fires once as expected. When it’s set togo
,search
and a few others, it fires twice. Maybe the core problem lies somewhere deeper down in Android, but if React-Native wants to keep the promises the documentation makes it’ll have to be dealt with.setting blurOnSubmit={false} worked for me on android