From b06672e6cf7eee1f94e535aef2c49d8f6d7e8e16 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Thu, 10 Aug 2017 18:09:35 -0700 Subject: [PATCH] TextInput: `onSubmitEditing` is now woriking with disabled `blurOnSubmit` Reviewed By: fmoo Differential Revision: D5606771 fbshipit-source-id: 6b769553c08c56b93036e517f71e011b6ecd779b --- Libraries/Text/RCTTextInput.m | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Libraries/Text/RCTTextInput.m b/Libraries/Text/RCTTextInput.m index 113b8b56b..4c63c2ef4 100644 --- a/Libraries/Text/RCTTextInput.m +++ b/Libraries/Text/RCTTextInput.m @@ -117,16 +117,23 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) - (BOOL)textInputShouldReturn { - return _blurOnSubmit; -} - -- (void)textInputDidReturn -{ + // We send `submit` event here, in `textInputShouldReturn` + // (not in `textInputDidReturn)`, because of semantic of the event: + // `onSubmitEditing` is called when "Submit" button + // (the blue key on onscreen keyboard) did pressed + // (no connection to any specific "submitting" process). [_eventDispatcher sendTextEventWithType:RCTTextEventTypeSubmit reactTag:self.reactTag text:self.backedTextInputView.text key:nil eventCount:_nativeEventCount]; + + return _blurOnSubmit; +} + +- (void)textInputDidReturn +{ + // Does nothing. } - (void)textInputDidChangeSelection