Skip to content

Commit d565bc3

Browse files
gontovnikfacebook-github-bot
authored andcommitted
Fix TextInput numeric keyboard submit
Summary: When you have a numeric non-multiline `TextInput` and a `returnKeyType` is `done` we automatically add an input accessory view ([implementation](https://github.com/facebook/react-native/blob/603cc48ceba001827d10231d51b4031c7768eef8/Libraries/Text/RCTTextInput.m#L269#L315)). That view has a done button which triggers [handleInputAccessoryDoneButton](https://github.com/facebook/react-native/blob/603cc48ceba001827d10231d51b4031c7768eef8/Libraries/Text/RCTTextInput.m#L317...L320) which currently directly sends `endEditing:` to the text field / text view. As a consequence, the [textInputShouldReturn](https://github.com/facebook/react-native/blob/603cc48ceba001827d10231d51b4031c7768eef8/Libraries/Text/RCTTextInput.m#L118...L121) is not called and we dismiss the keyboard even if the `blurOnSubmit` value is `false`. Confirm that the keyboard is not dismissed when you tap on Done button on this `TextInput`: ``` <TextInput keyboardType={'numeric'} returnKeyType={'done'} blurOnSubmit={false} /> ``` and that the keyboard is dismissed for this `TextInput`: ``` <TextInput keyboardType={'numeric'} returnKeyType={'done'} blurOnSubmit /> ``` Closes #15438 Differential Revision: D5601462 Pulled By: javache fbshipit-source-id: 24e4048e2e66d1a42fa97d83b4a3eb61e5d817ea
1 parent 9075ff6 commit d565bc3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Libraries/Text/RCTTextInput.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ - (void)invalidateInputAccessoryView
316316

317317
- (void)handleInputAccessoryDoneButton
318318
{
319-
[self.backedTextInputView endEditing:YES];
319+
if ([self textInputShouldReturn]) {
320+
[self.backedTextInputView endEditing:YES];
321+
}
320322
}
321323

322324
@end

0 commit comments

Comments
 (0)