Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type PressHandlerProps from './types';

function createPressHandler(onPress?: () => void): PressHandlerProps {
return {
onPress,
};
}

export default createPressHandler;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type {ButtonProps} from '@components/Button';
import type PressableProps from '@components/Pressable/GenericPressable/types';

type PressHandlerProps = Pick<PressableProps & ButtonProps, 'onPressIn' | 'onPress'>;

export default PressHandlerProps;
27 changes: 7 additions & 20 deletions src/components/ProductTrainingContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

Expand Down Expand Up @@ -301,26 +301,11 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
</Text>
{!tooltip?.shouldRenderActionButtons && (
<PressableWithoutFeedback
// On some Samsung devices, `onPress` is never triggered.
// So, we use `onPressIn` for Android to ensure the button is pressable.
onPressIn={
getPlatform() === CONST.PLATFORM.ANDROID
? () => {
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))}
>
<Icon
src={Expensicons.Close}
Expand All @@ -337,12 +322,14 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
success
text={translate('productTrainingTooltip.scanTestTooltip.tryItOut')}
style={[styles.flex1]}
onPress={config.onConfirm}
// eslint-disable-next-line react/jsx-props-no-spreading
{...createPressHandler(config.onConfirm)}
/>
<Button
text={translate('productTrainingTooltip.scanTestTooltip.noThanks')}
style={[styles.flex1]}
onPress={config.onDismiss}
// eslint-disable-next-line react/jsx-props-no-spreading
{...createPressHandler(config.onDismiss)}
/>
</View>
)}
Expand Down