Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

[iOS] onSelection not called on remounted component #72

Open
Reeywhaar opened this issue Mar 29, 2021 · 1 comment
Open

[iOS] onSelection not called on remounted component #72

Reeywhaar opened this issue Mar 29, 2021 · 1 comment

Comments

@Reeywhaar
Copy link

Reeywhaar commented Mar 29, 2021

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

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

@Reeywhaar
Copy link
Author

What I noticed else is that neither forwardInvocation nor canPerformAction are called on remounted component but called on first mount.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant