From 7da5ef372c5a1800c468194a76b958517779375b Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 18 Jul 2017 14:33:54 -0700 Subject: [PATCH] TextInput: Simplified `selectTextOnFocus` logic Summary: Previous implementation was not quite correct (because it was framed by hacky event handling) and caused some issues with new ScrollView improvements (autoscroll to focused TextInput). Reviewed By: javache Differential Revision: D5414439 fbshipit-source-id: 72d1f23170340c453b939dca8b72422822acc1d7 --- Libraries/Text/RCTTextInput.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Libraries/Text/RCTTextInput.m b/Libraries/Text/RCTTextInput.m index 0bc57b8b8..0927d47ba 100644 --- a/Libraries/Text/RCTTextInput.m +++ b/Libraries/Text/RCTTextInput.m @@ -95,12 +95,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) - (BOOL)textInputShouldBeginEditing { - if (_selectTextOnFocus) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.backedTextInputView selectAll:nil]; - }); - } - return YES; } @@ -110,6 +104,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) self.backedTextInputView.text = @""; } + if (_selectTextOnFocus) { + [self.backedTextInputView selectAll:nil]; + } + [_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus reactTag:self.reactTag text:self.backedTextInputView.text