WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

[iOS] onSelection not called on remounted component #72

@Reeywhaar

Description

@Reeywhaar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions