Skip to content

Commit

Permalink
Back out "[react-native][PR] [iOS] Fixes selection of single line tex…
Browse files Browse the repository at this point in the history
…t input"

Summary:
Original commit changeset: f149721d6b4d (D15238379)

This commit was causing the following crash: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x7fb3453eda00 of class RCTUITextField was deallocated while key value observers were still registered with it.

FB: See also P64445585 T44107377 T44169319

Reviewed By: mmmulani

Differential Revision: D15323255

fbshipit-source-id: 037c34ae387d912c5ea03eaa364b8c60367df357
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed May 13, 2019
1 parent 2cdf969 commit 0c11d8d
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,15 @@ - (instancetype)initWithTextField:(UITextField<RCTBackedTextInputViewProtocol> *

[_backedTextInputView addTarget:self action:@selector(textFieldDidChange) forControlEvents:UIControlEventEditingChanged];
[_backedTextInputView addTarget:self action:@selector(textFieldDidEndEditingOnExit) forControlEvents:UIControlEventEditingDidEndOnExit];
[_backedTextInputView addObserver:self forKeyPath:@"selectedTextRange" options:NSKeyValueObservingOptionNew context:NULL];
}

return self;
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
// UITextField doesn't have a delegate like UITextView to get notified on selection. Use KVO to observe changes.
if ([keyPath isEqualToString:@"selectedTextRange"]) {
[self textFieldProbablyDidChangeSelection];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}

- (void)dealloc
{
[_backedTextInputView removeTarget:self action:nil forControlEvents:UIControlEventEditingChanged];
[_backedTextInputView removeTarget:self action:nil forControlEvents:UIControlEventEditingDidEndOnExit];
[_backedTextInputView removeObserver:self forKeyPath:@"selectedTextRange"];
}

#pragma mark - UITextFieldDelegate
Expand Down

0 comments on commit 0c11d8d

Please sign in to comment.