-
Notifications
You must be signed in to change notification settings - Fork 109
[iOS] onSelection not called on remounted component #72
Description
Prerequisites
iOS 11.4
react-native 0.64
react-native-selectable-text 1.5.1
What happens
App uses react-native-navigation and displays SelectableText in Overlay. SelectableText has one action — Copy. Action handler copies selected text to clipboard and dismisses Overlay. Problem is that onSelection is called only on first mount of Overlay. Reopening Overlay, then selecting text and clicking on menu item does nothing: text not copied, overlay not dismissed.
What is known so far
Problem happens only on ios.
Problem is located somewhere in hitTest action in RNSelectableTextView.m
react-native-selectable-text/ios/RNSelectableTextView.m
Lines 248 to 273 in 7ab5e75
| - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event | |
| { | |
| if (!_backedTextInputView.isFirstResponder) { | |
| [_backedTextInputView setSelectedTextRange:nil notifyDelegate:true]; | |
| } else { | |
| UIView *sub = nil; | |
| for (UIView *subview in self.subviews.reverseObjectEnumerator) { | |
| CGPoint subPoint = [subview convertPoint:point toView:self]; | |
| UIView *result = [subview hitTest:subPoint withEvent:event]; | |
| if (!result.isFirstResponder) { | |
| NSString *name = NSStringFromClass([result class]); | |
| if ([name isEqual:@"UITextRangeView"]) { | |
| sub = result; | |
| } | |
| } | |
| } | |
| if (sub == nil) { | |
| [_backedTextInputView setSelectedTextRange:nil notifyDelegate:true]; | |
| } | |
| } | |
| return [super hitTest:point withEvent:event]; | |
| } |
If I remove else branch (lines 253-269) then problem is gone, though I not yet understand what is purpose of else branch