From d565bc3e3f268274afb672377cdeb42d4a84aa5b Mon Sep 17 00:00:00 2001 From: Danil Gontovnik Date: Thu, 10 Aug 2017 03:24:06 -0700 Subject: [PATCH] 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`: ``` ``` and that the keyboard is dismissed for this `TextInput`: ``` ``` Closes https://github.com/facebook/react-native/pull/15438 Differential Revision: D5601462 Pulled By: javache fbshipit-source-id: 24e4048e2e66d1a42fa97d83b4a3eb61e5d817ea --- Libraries/Text/RCTTextInput.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/Text/RCTTextInput.m b/Libraries/Text/RCTTextInput.m index 3833008fc..113b8b56b 100644 --- a/Libraries/Text/RCTTextInput.m +++ b/Libraries/Text/RCTTextInput.m @@ -316,7 +316,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) - (void)handleInputAccessoryDoneButton { - [self.backedTextInputView endEditing:YES]; + if ([self textInputShouldReturn]) { + [self.backedTextInputView endEditing:YES]; + } } @end