From b09903e3b84af5f00d73b3f68dd71f04e6691def Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 22 Apr 2024 21:29:29 +0100 Subject: [PATCH] only open tag menu on long press (#3553) --- src/components/RichText.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/RichText.tsx b/src/components/RichText.tsx index 82cdda1076..0d49e7130d 100644 --- a/src/components/RichText.tsx +++ b/src/components/RichText.tsx @@ -2,7 +2,9 @@ import React from 'react' import {AppBskyRichtextFacet, RichText as RichTextAPI} from '@atproto/api' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {useNavigation} from '@react-navigation/native' +import {NavigationProp} from '#/lib/routes/types' import {toShortUrl} from '#/lib/strings/url-helpers' import {isNative} from '#/platform/detection' import {atoms as a, flatten, native, TextStyleProp, useTheme, web} from '#/alf' @@ -178,8 +180,15 @@ function RichTextTag({ onIn: onPressIn, onOut: onPressOut, } = useInteractionState() + const navigation = useNavigation() - const open = React.useCallback(() => { + const navigateToPage = React.useCallback(() => { + navigation.push('Hashtag', { + tag: encodeURIComponent(tag), + }) + }, [navigation, tag]) + + const openDialog = React.useCallback(() => { control.open() }, [control]) @@ -195,9 +204,10 @@ function RichTextTag({ selectable={selectable} {...native({ accessibilityLabel: _(msg`Hashtag: #${tag}`), - accessibilityHint: _(msg`Click here to open tag menu for #${tag}`), + accessibilityHint: _(msg`Long press to open tag menu for #${tag}`), accessibilityRole: isNative ? 'button' : undefined, - onPress: open, + onPress: navigateToPage, + onLongPress: openDialog, onPressIn: onPressIn, onPressOut: onPressOut, })}