Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

In my React Native application, I have two TextInput components, one numeric and one default. The problem is that, onSubmitEditing works on the default keyboard on both iOS and Android, but it's not triggered on the numeric keyboard on iOS.

Default keyboard:

I use the default keyboardType in the example below. onSubmitEditing is triggered both on Android and iOS.

<TextInput
        value={this.state.username}
        onChangeText={(username) => this.setState({ username })}
        onSubmitEditing={() => console.log('onSubmitEditing triggered')}

Android keyboard has a tick-button and iOS keyboard has a return button. When I press these buttons, onSubmitEditing is triggered on both keyboards.

Numeric keyboard:

I used the numeric keyboardType in the following example. I added returnKeyType="done", because iOS keyboard does now show a button without setting returnKeyType.

<TextInput
        value={this.state.password}
        keyboardType="numeric"
        onChangeText={(password) => this.setState({ password })}
        onSubmitEditing={() => console.log('onSubmitEditing triggered')}
        returnKeyType="done"

Android keyboard shows a tick-button and it triggers onSubmitEditing when pressed. iOS keyboard shows a Done button above the keyboard, however it does not trigger onSubmitEditing.

It looks like it should work. I have almost exactly the same code and it works. Did you get it working? – Magne Jun 12, 2018 at 14:49 @Magne no, it does not work on iOS. It's still a big problem and I always have to find a workaround. I try using onEndEditing on iOS, but it's not only triggered on clicking Done button but also clicking somewhere else too. Does it work on an iPhone? – Faruk Yazici Jun 12, 2018 at 15:14 How strange.. I have an iPhone 6S and it works on it. Note: for some reason the returnKeyType has to be "done" for it to show up on my iPhone. It can't be "next", "send" or "go" or any of the other words the documentation says is allowed. – Magne Jun 13, 2018 at 10:50

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.