From 4a2bc89f301c16ea2fd4d0155853e5937e89b197 Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Thu, 20 Oct 2022 11:17:26 +0530 Subject: [PATCH 1/9] onKeyDown added to textlink component --- src/components/TextLink.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index 8a56af8341ad..e8d55fd9185d 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -32,19 +32,29 @@ const defaultProps = { const TextLink = (props) => { const additionalStyles = _.isArray(props.style) ? props.style : [props.style]; + + const handlePress = (e) => { + e.preventDefault(); + if (props.onPress) { + props.onPress(); + return; + } + + Linking.openURL(props.href); + }; + return ( { - e.preventDefault(); - if (props.onPress) { - props.onPress(); + onPress={handlePress} + onKeyDown={(e) => { + if (e.key !== 'Enter') { return; } - Linking.openURL(props.href); + handlePress(e); }} > {props.children} From b7b242b13d34f5b17d80ee4dfc94805c8af0348a Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Mon, 24 Oct 2022 14:23:26 +0530 Subject: [PATCH 2/9] Rename Function & Move Callback --- src/components/TextLink.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index e8d55fd9185d..07a8f64ae4c9 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -33,8 +33,19 @@ const defaultProps = { const TextLink = (props) => { const additionalStyles = _.isArray(props.style) ? props.style : [props.style]; - const handlePress = (e) => { - e.preventDefault(); + /** + * Checking Function on open TextLink identify whether Clicked or Entered key press + * + * @param {Event} event + * @returns {Function} Returns onPress function. + */ + + const openLink = (event) => { + if (event.key !== 'Enter' && event.type !== 'click') { + return; + } + + event.preventDefault(); if (props.onPress) { props.onPress(); return; @@ -48,14 +59,8 @@ const TextLink = (props) => { style={[styles.link, ...additionalStyles]} accessibilityRole="link" href={props.href} - onPress={handlePress} - onKeyDown={(e) => { - if (e.key !== 'Enter') { - return; - } - - handlePress(e); - }} + onPress={openLink} + onKeyDown={openLink} > {props.children} From 58046cc46673a301b5c72055dded73f80350802c Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Mon, 24 Oct 2022 19:52:54 +0530 Subject: [PATCH 3/9] Removed Obsolete parameter from JsDoc --- src/components/TextLink.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index 07a8f64ae4c9..62fe9874a268 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -37,7 +37,6 @@ const TextLink = (props) => { * Checking Function on open TextLink identify whether Clicked or Entered key press * * @param {Event} event - * @returns {Function} Returns onPress function. */ const openLink = (event) => { From 5e5d2e7bf23079bbd42cdba7a989d29e30c225aa Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Fri, 28 Oct 2022 09:38:16 +0530 Subject: [PATCH 4/9] Adding onKeyDown condition --- src/components/TextLink.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index 62fe9874a268..4bf6634e2d34 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -40,10 +40,6 @@ const TextLink = (props) => { */ const openLink = (event) => { - if (event.key !== 'Enter' && event.type !== 'click') { - return; - } - event.preventDefault(); if (props.onPress) { props.onPress(); @@ -59,7 +55,12 @@ const TextLink = (props) => { accessibilityRole="link" href={props.href} onPress={openLink} - onKeyDown={openLink} + onKeyDown={(e) => { + if (e.key !== 'Enter') { + return; + } + openLink(e); + }} > {props.children} From 3ab018ec23845726ffbb3a529b61431ef063f097 Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Tue, 1 Nov 2022 09:27:26 +0530 Subject: [PATCH 5/9] Removed Obsolute comment --- src/components/TextLink.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index 4bf6634e2d34..6a949273daee 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -34,7 +34,6 @@ const TextLink = (props) => { const additionalStyles = _.isArray(props.style) ? props.style : [props.style]; /** - * Checking Function on open TextLink identify whether Clicked or Entered key press * * @param {Event} event */ From 2a654dbce56643311e2ae024ae1f4b5f5329f5dd Mon Sep 17 00:00:00 2001 From: Dhairya <47522946+dhairyasenjaliya@users.noreply.github.com> Date: Wed, 2 Nov 2022 20:25:47 +0530 Subject: [PATCH 6/9] Update src/components/TextLink.js Co-authored-by: e_voloshchak --- src/components/TextLink.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index 6a949273daee..8e20b9a58ead 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -34,7 +34,6 @@ const TextLink = (props) => { const additionalStyles = _.isArray(props.style) ? props.style : [props.style]; /** - * * @param {Event} event */ From a056f80e49c5b270f21a4656a2a2de402bef9cdf Mon Sep 17 00:00:00 2001 From: Dhairya <47522946+dhairyasenjaliya@users.noreply.github.com> Date: Wed, 2 Nov 2022 20:54:09 +0530 Subject: [PATCH 7/9] Update src/components/TextLink.js Co-authored-by: Tim Golen --- src/components/TextLink.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index 8e20b9a58ead..f35cb7b36b49 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -36,7 +36,6 @@ const TextLink = (props) => { /** * @param {Event} event */ - const openLink = (event) => { event.preventDefault(); if (props.onPress) { From a4b84bc8f63b162633e878cc4379c000a31f3051 Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Thu, 3 Nov 2022 22:22:06 +0530 Subject: [PATCH 8/9] move callback --- src/components/TextLink.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index f35cb7b36b49..8ee0e2bfea9b 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -46,18 +46,25 @@ const TextLink = (props) => { Linking.openURL(props.href); }; + /** + * + * @param {Event} event + */ + + const openLinkIfEnterKeyPressed = (event) => { + if (event.key !== 'Enter') { + return; + } + openLink(event); + }; + return ( { - if (e.key !== 'Enter') { - return; - } - openLink(e); - }} + onKeyDown={openLinkIfEnterKeyPressed} > {props.children} From d0ad7de988a88bcf4f2de61053968ba9c9faad0f Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Thu, 3 Nov 2022 22:34:30 +0530 Subject: [PATCH 9/9] Remove Obsolute lines --- src/components/TextLink.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/TextLink.js b/src/components/TextLink.js index 8ee0e2bfea9b..55344d987139 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -47,10 +47,8 @@ const TextLink = (props) => { }; /** - * * @param {Event} event */ - const openLinkIfEnterKeyPressed = (event) => { if (event.key !== 'Enter') { return;