Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onHighlightPress property is not working on IOS OS 16+ #14

Open
react3-moon opened this issue Jan 16, 2023 · 10 comments
Open

onHighlightPress property is not working on IOS OS 16+ #14

react3-moon opened this issue Jan 16, 2023 · 10 comments

Comments

@react3-moon
Copy link

onHighlightPress property is not working on IOS OS 16+

    "react": "17.0.2",
    "react-native": "0.67.2",
    "@alentoma/react-native-selectable-text": "1.6.0",

below mentioned code always return 0 for clickedRangeStart & clickedRangeEnd.

-(void) handleSingleTap: (UITapGestureRecognizer *) gesture
{
    CGPoint pos = [gesture locationInView:_backedTextInputView];
    pos.y += _backedTextInputView.contentOffset.y;
    
    UITextPosition *tapPos = [_backedTextInputView closestPositionToPoint:pos];
    UITextRange *word = [_backedTextInputView.tokenizer rangeEnclosingPosition:tapPos withGranularity:(UITextGranularityWord) inDirection:UITextLayoutDirectionRight];
    
    UITextPosition* beginning = _backedTextInputView.beginningOfDocument;
    
    UITextPosition *selectionStart = word.start;
    UITextPosition *selectionEnd = word.end;
    
    const NSInteger location = [_backedTextInputView offsetFromPosition:beginning toPosition:selectionStart];
    const NSInteger endLocation = [_backedTextInputView offsetFromPosition:beginning toPosition:selectionEnd];
    
    self.onHighlightPress(@{
        @"clickedRangeStart": @(location),
        @"clickedRangeEnd": @(endLocation),
    });
}

@AlenToma

@AlenToma
Copy link
Owner

Sadly I dont own IOS or mac so I can't fix this if it is really an issue.

But no body have complained about this so I dont know if the issue is really with the library.

If someone could test this?

@Harshkansaramoon
Copy link

I am also facing the same issue. is any one have luck?

@AlenToma
Copy link
Owner

AlenToma commented Jan 18, 2023

I have build another library may be as a replacement.

https://github.com/AlenToma/react-native-text-contextmenu

@Harshkansaramoon
Copy link

Harshkansaramoon commented Jan 18, 2023

@AlenToma thank you for your support.
for now I changed in native library code of your and I replace this line
UITextRange *word = [_backedTextInputView.tokenizer rangeEnclosingPosition:tapPos withGranularity:(UITextGranularityWord) inDirection: inDirection:UITextLayoutDirectionRight];
to
UITextRange *word = [_backedTextInputView.tokenizer rangeEnclosingPosition:tapPos withGranularity:(UITextGranularityWord) inDirection:UITextWritingDirectionNatural];

and its work for me in all versions of IOS.

@ZainabShakeel
Copy link

Hey
im facing issue with selection text on higher version of IOS
lower versions are working fine

@Harshkansaramoon can you please let me know which file did you updated for the fix?

@Harshkansaramoon
Copy link

@ZainabShakeel in this I changed file RNSelectableTextView.m

@ZainabShakeel
Copy link

yes found @Harshkansaramoon Thanks a lot.

@Bourne007-13
Copy link

Bourne007-13 commented Feb 20, 2023

@Harshkansaramoon Have you got app crash when long press a word and swipe right ?whether some new feature update caused this issue on ios 16?

@AlenToma
Copy link
Owner

@Harshkansaramoon could you check in your version of the fix and I will do pull and publish it.

@react3-moon
Copy link
Author

Hi, we have implemented https://www.npmjs.com/package/@vandrei977/react-native-selectable-text and that is forked from this library. We are not getting any crash.

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

No branches or pull requests

5 participants