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
This commit is contained in:
Valentin Shergin 2017-07-18 14:33:54 -07:00 committed by Facebook Github Bot
parent 1d22f8fb27
commit 7da5ef372c
1 changed files with 4 additions and 6 deletions

View File

@ -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