about summary refs log tree commit diff
path: root/src/view/com/util/Link.tsx
diff options
context:
space:
mode:
authorAnsh <anshnanda10@gmail.com>2023-07-06 18:41:27 -0700
committerGitHub <noreply@github.com>2023-07-06 20:41:27 -0500
commitdf7552135a50d715a50ab592874eb84fc7c8bbcf (patch)
treebc107dec5ee45a57d3e97980136eb9a7dabfda1d /src/view/com/util/Link.tsx
parentbf1785765d47c08d7f04c50b3bfd6c04a1bc795b (diff)
downloadvoidsky-df7552135a50d715a50ab592874eb84fc7c8bbcf.tar.zst
[APP-703] Android horizontal scroll registers as tap (#960)
* use Touchables from react-native-gesture-handler

* upgrade `react-native-gesture-handler` to latest version

* add FixedTouchableHighlight for android

* add workaround comment

* wait for animations to complete before loading data

* downgrade RNGH back to the version we had
Diffstat (limited to 'src/view/com/util/Link.tsx')
-rw-r--r--src/view/com/util/Link.tsx25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/view/com/util/Link.tsx b/src/view/com/util/Link.tsx
index 7ff896344..1dec97e78 100644
--- a/src/view/com/util/Link.tsx
+++ b/src/view/com/util/Link.tsx
@@ -5,11 +5,11 @@ import {
   GestureResponderEvent,
   Platform,
   StyleProp,
-  TouchableWithoutFeedback,
-  TouchableOpacity,
   TextStyle,
   View,
   ViewStyle,
+  TouchableOpacity,
+  TouchableWithoutFeedback,
 } from 'react-native'
 import {
   useLinkProps,
@@ -22,8 +22,9 @@ import {NavigationProp} from 'lib/routes/types'
 import {router} from '../../../routes'
 import {useStores, RootStoreModel} from 'state/index'
 import {convertBskyAppUrlIfNeeded, isExternalUrl} from 'lib/strings/url-helpers'
-import {isDesktopWeb} from 'platform/detection'
+import {isAndroid, isDesktopWeb} from 'platform/detection'
 import {sanitizeUrl} from '@braintree/sanitize-url'
+import FixedTouchableHighlight from '../pager/FixedTouchableHighlight'
 
 type Event =
   | React.MouseEvent<HTMLAnchorElement, MouseEvent>
@@ -65,6 +66,24 @@ export const Link = observer(function Link({
   )
 
   if (noFeedback) {
+    if (isAndroid) {
+      // workaround for Android not working well with left/right swipe gestures and TouchableWithoutFeedback
+      // https://github.com/callstack/react-native-pager-view/issues/424
+      return (
+        <FixedTouchableHighlight
+          testID={testID}
+          onPress={onPress}
+          // @ts-ignore web only -prf
+          href={asAnchor ? sanitizeUrl(href) : undefined}
+          accessible={accessible}
+          accessibilityRole="link"
+          {...props}>
+          <View style={style}>
+            {children ? children : <Text>{title || 'link'}</Text>}
+          </View>
+        </FixedTouchableHighlight>
+      )
+    }
     return (
       <TouchableWithoutFeedback
         testID={testID}