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

Commit 4b24fd6

Browse files
committed
fix(ios): ios 13 change selection bug
1 parent 1b32ac7 commit 4b24fd6

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

ios/RNSelectableTextView.m

+22-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,28 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
247247

248248
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
249249
{
250-
[_backedTextInputView setSelectedTextRange:nil notifyDelegate:true];
250+
if (!_backedTextInputView.isFirstResponder) {
251+
[_backedTextInputView setSelectedTextRange:nil notifyDelegate:true];
252+
} else {
253+
UIView *sub = nil;
254+
for (UIView *subview in self.subviews.reverseObjectEnumerator) {
255+
CGPoint subPoint = [subview convertPoint:point toView:self];
256+
UIView *result = [subview hitTest:subPoint withEvent:event];
257+
258+
if (!result.isFirstResponder) {
259+
NSString *name = NSStringFromClass([result class]);
260+
261+
if ([name isEqual:@"UITextRangeView"]) {
262+
sub = result;
263+
}
264+
}
265+
}
266+
267+
if (sub == nil) {
268+
[_backedTextInputView setSelectedTextRange:nil notifyDelegate:true];
269+
}
270+
}
271+
251272
return [super hitTest:point withEvent:event];
252273
}
253274

0 commit comments

Comments
 (0)