-
Notifications
You must be signed in to change notification settings - Fork 82
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
Links are no longer clickable/no onPress when selectable={true} #58
Comments
This seems to be a shortcoming of RN or potentially the underlying platform. I did a bit of testing with the Only thing I can think of to suggest would be to leave the onPress as is and implement a custom solution for copying the links using |
Ah, yeah, the problem here is we're dealing with text we don't know in advance, so we want to highlight and make that text clickable when it should be a link (and react-native-autolink works beautifully for that out of the box—great work). The copy-paste functionality is kind of secondary, so we're just going to roll with it as-is without it bing selectable. Though the |
Well, I got it working sort of—still can't copy and paste non-link text, but if they just wanted the link, In the process I also learned that react-native Clipboard is deprecated, but the commons clipboard they recommend doesn't work. 🤣 |
I'm trying to use autolink to render linkable text and allow clicking on URLs. Out of the box it works well, but when I set selectable={true}, I lose the clickability (you can copy and paste the link text, but clicking doesn't do anything). I've tried a couple of different tricks (making only the text selectable? trying to re-implement openURL in onPress), but these don't work either. It seems to be EITHER clickable links OR selectable text, not both.
By default, this doesn't allow selecting/copying/pasting, but links work without any custom onPress
<Autolink style={styles.subject} text={notification.subject} />
<Autolink style={styles.subject} text={notification.subject} textProps={{ selectable: true }} />
This allows selecting/copying/pasting, also highlights the URL's I want to be clickable, but they're not.
<Autolink style={styles.subject} text={notification.subject} selectable={true} />
This is just a flail that will clickable links, but plain text not selectable (even though it's explicitly specified true):
<Autolink style={styles.subject} text={notification.subject} textProps={{ selectable: true }} onPress={(url) => { Linking.openURL(url); }} />
This is another stab at it that that results in selectable but not clickable links (basically the base behavior with selectable={true}):
<Autolink style={styles.subject} text={notification.subject} selectable={true} onPress={(url) => { Linking.openURL(url); }} />
Is that working as designed or should I be able to get clickable and highlightable text (the way hypertext works on a browser)?
The text was updated successfully, but these errors were encountered: