Permalink
Browse files

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
  • Loading branch information...
shergin authored and facebook-github-bot committed Jul 18, 2017
1 parent 1d22f8f commit 7da5ef372c5a1800c468194a76b958517779375b
Showing with 4 additions and 6 deletions.
  1. +4 −6 Libraries/Text/RCTTextInput.m
@@ -95,12 +95,6 @@ - (void)setSelection:(RCTTextSelection *)selection
- (BOOL)textInputShouldBeginEditing
{
if (_selectTextOnFocus) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.backedTextInputView selectAll:nil];
});
}
return YES;
}
@@ -110,6 +104,10 @@ - (void)textInputDidBeginEditing
self.backedTextInputView.text = @"";
}
if (_selectTextOnFocus) {
[self.backedTextInputView selectAll:nil];
}
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus
reactTag:self.reactTag
text:self.backedTextInputView.text

0 comments on commit 7da5ef3

Please sign in to comment.