Skip to content

Commit

Permalink
[QA-955] Dismiss keyboard when clicking external link (#8375)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjeffers committed May 7, 2024
1 parent ba93306 commit 32746d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/mobile/src/components/core/Hyperlink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const Hyperlink = (props: HyperlinkProps) => {
source,
styles: stylesProp,
style,
onPress,
...other
} = props
const styles = useStyles()
Expand Down Expand Up @@ -104,7 +105,8 @@ export const Hyperlink = (props: HyperlinkProps) => {
const { onOpen: openLeavingAudiusModal } = useLeavingAudiusModal()

const handlePress = useCallback(
(url: string) => {
(url: string, _match: Match) => {
onPress?.(url, _match)
if (isInteralAudiusUrl(url)) {
const path = getPathFromAudiusUrl(url)
if (path) {
Expand All @@ -116,7 +118,7 @@ export const Hyperlink = (props: HyperlinkProps) => {
openLeavingAudiusModal({ link: url })
}
},
[linkTo, openLink, openLeavingAudiusModal]
[onPress, linkTo, openLink, openLeavingAudiusModal]
)

const renderLink = useCallback(
Expand Down Expand Up @@ -182,7 +184,7 @@ export const Hyperlink = (props: HyperlinkProps) => {
left: linkLayout.x - linkContainerLayout.x
}
]}
onPress={() => handlePress(match.getAnchorHref())}
onPress={() => handlePress(match.getAnchorHref(), match)}
>
{text}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type InternalProps = {
}

export type TextInputProps = RNTextInputProps & {
id?: string
/**
* Input sizes. NOTE: small inputs will not show the label
* @default default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import type { ChatMessageReaction } from '@audius/sdk'
import { find } from 'linkifyjs'
import type { ViewStyle, StyleProp } from 'react-native'
import { Dimensions, View } from 'react-native'
import { Dimensions, Keyboard, View } from 'react-native'
import { useSelector } from 'react-redux'

import ChatTail from 'app/assets/images/ChatTail.svg'
Expand Down Expand Up @@ -322,6 +322,7 @@ export const ChatMessageListItem = memo(function ChatMessageListItem(
]}
>
<Hyperlink
onPress={Keyboard.dismiss}
text={message.message}
styles={{
root: [
Expand Down

0 comments on commit 32746d6

Please sign in to comment.