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

onKeyDown added to Textlink component #12034

Merged
merged 14 commits into from
Nov 3, 2022
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/components/TextLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,33 @@ const defaultProps = {

const TextLink = (props) => {
const additionalStyles = _.isArray(props.style) ? props.style : [props.style];

/**
*
dhairyasenjaliya marked this conversation as resolved.
Show resolved Hide resolved
* @param {Event} event
*/

const openLink = (event) => {
dhairyasenjaliya marked this conversation as resolved.
Show resolved Hide resolved
event.preventDefault();
if (props.onPress) {
props.onPress();
return;
}

Linking.openURL(props.href);
};

return (
<Text
style={[styles.link, ...additionalStyles]}
accessibilityRole="link"
href={props.href}
onPress={(e) => {
e.preventDefault();
if (props.onPress) {
props.onPress();
onPress={openLink}
onKeyDown={(e) => {
dhairyasenjaliya marked this conversation as resolved.
Show resolved Hide resolved
if (e.key !== 'Enter') {
return;
}

Linking.openURL(props.href);
openLink(e);
}}
>
{props.children}
Expand Down