diff --git a/src/components/ProductTrainingContext/createPressHandler/index.android.ts b/src/components/ProductTrainingContext/createPressHandler/index.android.ts new file mode 100644 index 0000000000000..1fd17cf026415 --- /dev/null +++ b/src/components/ProductTrainingContext/createPressHandler/index.android.ts @@ -0,0 +1,14 @@ +import type PressHandlerProps from './types'; + +/** + * This is a workaround for a known issue on certain Samsung Android devices + * So, we use `onPressIn` for Android to ensure the button is pressable. + * This will be removed once the issue https://github.com/Expensify/App/issues/59953 is resolved. + */ +function createPressHandler(onPress?: () => void): PressHandlerProps { + return { + onPressIn: onPress, + }; +} + +export default createPressHandler; diff --git a/src/components/ProductTrainingContext/createPressHandler/index.ts b/src/components/ProductTrainingContext/createPressHandler/index.ts new file mode 100644 index 0000000000000..4de60a9716fcd --- /dev/null +++ b/src/components/ProductTrainingContext/createPressHandler/index.ts @@ -0,0 +1,9 @@ +import type PressHandlerProps from './types'; + +function createPressHandler(onPress?: () => void): PressHandlerProps { + return { + onPress, + }; +} + +export default createPressHandler; diff --git a/src/components/ProductTrainingContext/createPressHandler/types.ts b/src/components/ProductTrainingContext/createPressHandler/types.ts new file mode 100644 index 0000000000000..90c464216c2a4 --- /dev/null +++ b/src/components/ProductTrainingContext/createPressHandler/types.ts @@ -0,0 +1,6 @@ +import type {ButtonProps} from '@components/Button'; +import type PressableProps from '@components/Pressable/GenericPressable/types'; + +type PressHandlerProps = Pick; + +export default PressHandlerProps; diff --git a/src/components/ProductTrainingContext/index.tsx b/src/components/ProductTrainingContext/index.tsx index 1d09204447f93..bcce5f07858de 100644 --- a/src/components/ProductTrainingContext/index.tsx +++ b/src/components/ProductTrainingContext/index.tsx @@ -12,7 +12,6 @@ import useSidePanel from '@hooks/useSidePanel'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {parseFSAttributes} from '@libs/Fullstory'; -import getPlatform from '@libs/getPlatform'; import {hasCompletedGuidedSetupFlowSelector} from '@libs/onboardingSelectors'; import {getActiveAdminWorkspaces, getActiveEmployeeWorkspaces} from '@libs/PolicyUtils'; import isProductTrainingElementDismissed from '@libs/TooltipUtils'; @@ -21,6 +20,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type ChildrenProps from '@src/types/utils/ChildrenProps'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; +import createPressHandler from './createPressHandler'; import type {ProductTrainingTooltipName} from './TOOLTIPS'; import TOOLTIPS from './TOOLTIPS'; @@ -301,26 +301,11 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou {!tooltip?.shouldRenderActionButtons && ( { - hideTooltip(true); - } - : undefined - } - // For other platforms, we stick with `onPress`. - onPress={ - getPlatform() !== CONST.PLATFORM.ANDROID - ? () => { - hideTooltip(true); - } - : undefined - } shouldUseAutoHitSlop accessibilityLabel={translate('productTrainingTooltip.scanTestTooltip.noThanks')} role={CONST.ROLE.BUTTON} + // eslint-disable-next-line react/jsx-props-no-spreading + {...createPressHandler(() => hideTooltip(true))} >