question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] onSubmitEditing is called twice when keyboard is dismissed in android

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
iggyfiskcommented, Sep 26, 2016

Confirming that this occurs on Android 6.0.1, both simulator and device. However it only happens when using certain returnKeyType values. If returnKeyType is omitted, the event only fires once as expected. When it’s set to go, 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.

6reactions
rangavcommented, Jan 21, 2017

setting blurOnSubmit={false} worked for me on android

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found