only open tag menu on long press (#3553)
parent
bcd88b088a
commit
b09903e3b8
|
@ -2,7 +2,9 @@ import React from 'react'
|
||||||
import {AppBskyRichtextFacet, RichText as RichTextAPI} from '@atproto/api'
|
import {AppBskyRichtextFacet, RichText as RichTextAPI} from '@atproto/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
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 {toShortUrl} from '#/lib/strings/url-helpers'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
import {atoms as a, flatten, native, TextStyleProp, useTheme, web} from '#/alf'
|
import {atoms as a, flatten, native, TextStyleProp, useTheme, web} from '#/alf'
|
||||||
|
@ -178,8 +180,15 @@ function RichTextTag({
|
||||||
onIn: onPressIn,
|
onIn: onPressIn,
|
||||||
onOut: onPressOut,
|
onOut: onPressOut,
|
||||||
} = useInteractionState()
|
} = useInteractionState()
|
||||||
|
const navigation = useNavigation<NavigationProp>()
|
||||||
|
|
||||||
const open = React.useCallback(() => {
|
const navigateToPage = React.useCallback(() => {
|
||||||
|
navigation.push('Hashtag', {
|
||||||
|
tag: encodeURIComponent(tag),
|
||||||
|
})
|
||||||
|
}, [navigation, tag])
|
||||||
|
|
||||||
|
const openDialog = React.useCallback(() => {
|
||||||
control.open()
|
control.open()
|
||||||
}, [control])
|
}, [control])
|
||||||
|
|
||||||
|
@ -195,9 +204,10 @@ function RichTextTag({
|
||||||
selectable={selectable}
|
selectable={selectable}
|
||||||
{...native({
|
{...native({
|
||||||
accessibilityLabel: _(msg`Hashtag: #${tag}`),
|
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,
|
accessibilityRole: isNative ? 'button' : undefined,
|
||||||
onPress: open,
|
onPress: navigateToPage,
|
||||||
|
onLongPress: openDialog,
|
||||||
onPressIn: onPressIn,
|
onPressIn: onPressIn,
|
||||||
onPressOut: onPressOut,
|
onPressOut: onPressOut,
|
||||||
})}
|
})}
|
||||||
|
|
Loading…
Reference in New Issue