Skip to content

Links are no longer clickable/no onPress when selectable={true} #58

@MaxPMagee

Description

@MaxPMagee

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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions