Skip to content

Commit

Permalink
Revert "(PC-22272) feat(accessibility): enable cmd + clic for Touchab…
Browse files Browse the repository at this point in the history
…leLink in web (#5078)" (#5092)

This reverts commit b5bae8f.
  • Loading branch information
aliraiki authored Jul 31, 2023
1 parent a248ddf commit 2c8c7ce
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 124 deletions.
10 changes: 7 additions & 3 deletions src/ui/components/touchableLink/TouchableLink.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import debounce from 'lodash/debounce'
import React, { createRef, ElementType, useCallback, useEffect } from 'react'
import { NativeSyntheticEvent, Platform, TargetedEvent } from 'react-native'
import { GestureResponderEvent, NativeSyntheticEvent, Platform, TargetedEvent } from 'react-native'
import styled from 'styled-components/native'

import { accessibilityAndTestId } from 'libs/accessibilityAndTestId'
import { useHandleFocus } from 'libs/hooks/useHandleFocus'
import { useHandleHover } from 'libs/hooks/useHandleHover'
import { handleNavigationWrapper } from 'ui/components/touchableLink/handleNavigationWrapper'
import { TouchableLinkProps } from 'ui/components/touchableLink/types'
import { TouchableOpacity } from 'ui/components/TouchableOpacity'
// eslint-disable-next-line no-restricted-imports
Expand Down Expand Up @@ -46,7 +45,12 @@ export function TouchableLink({
? { ...linkProps, accessibilityRole: undefined }
: { accessibilityRole: 'link' }

const onClick = handleNavigationWrapper({ onBeforeNavigate, onAfterNavigate, handleNavigation })
async function onClick(event: GestureResponderEvent) {
Platform.OS === 'web' && event?.preventDefault()
if (onBeforeNavigate) await onBeforeNavigate(event)
handleNavigation()
if (onAfterNavigate) await onAfterNavigate(event)
}

const onLinkFocus = useCallback(
(e: NativeSyntheticEvent<TargetedEvent>) => {
Expand Down
78 changes: 0 additions & 78 deletions src/ui/components/touchableLink/TouchableLink.web.test.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions src/ui/components/touchableLink/handleNavigationWrapper.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/ui/components/touchableLink/handleNavigationWrapper.web.ts

This file was deleted.

9 changes: 2 additions & 7 deletions src/ui/components/touchableLink/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type AsProps = {
} & Record<string, unknown>

type TouchableLinkGenericProps = {
onBeforeNavigate?: (event: GestureResponderEvent | MouseEvent) => void
onAfterNavigate?: (event: GestureResponderEvent | MouseEvent) => void
onBeforeNavigate?: (event: GestureResponderEvent) => void
onAfterNavigate?: (event: GestureResponderEvent) => void
highlight?: boolean // If true, uses TouchableHighlight instead of TouchableOpacity to render component
hoverUnderlineColor?: ColorsEnum // Color to be used for underline effect on hover. Black if not specified
isOnPressDebounced?: boolean
Expand All @@ -62,8 +62,3 @@ export type TouchableLinkProps = TouchableLinkGenericProps & {
target: string
}
}

export type HandleNavigationWrapperProps = Pick<
TouchableLinkProps,
'handleNavigation' | 'onBeforeNavigate' | 'onAfterNavigate'
>

0 comments on commit 2c8c7ce

Please sign in to comment.