diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx index cfdc52bf96..038083b4c8 100644 --- a/src/components/Tooltip/Tooltip.tsx +++ b/src/components/Tooltip/Tooltip.tsx @@ -1,11 +1,5 @@ import * as React from 'react'; -import { - Dimensions, - View, - StyleSheet, - Platform, - Pressable, -} from 'react-native'; +import { Dimensions, View, StyleSheet, Platform } from 'react-native'; import type { LayoutChangeEvent, ViewStyle } from 'react-native'; import { getTooltipPosition } from './utils'; @@ -231,16 +225,16 @@ const Tooltip = ({ )} - {React.cloneElement(children, { ...rest, ...(Platform.OS === 'web' ? webPressProps : mobilePressProps), })} - + ); }; diff --git a/src/components/__tests__/Tooltip.test.tsx b/src/components/__tests__/Tooltip.test.tsx index f143109d9b..348d41dd08 100644 --- a/src/components/__tests__/Tooltip.test.tsx +++ b/src/components/__tests__/Tooltip.test.tsx @@ -509,5 +509,24 @@ describe('Tooltip', () => { }); }); }); + + it('does not wrap child in a pressable wrapper', async () => { + const onPress = jest.fn(); + const { + wrapper: { getByText }, + } = await setup({ + children: , + }); + + const wrapperView = getTrigger(getByText).parent; + expect(wrapperView).toBeTruthy(); + if (wrapperView) { + await userEvent.press(wrapperView); + } + expect(onPress).not.toHaveBeenCalled(); + + await userEvent.press(getTrigger(getByText)); + expect(onPress).toHaveBeenCalledTimes(1); + }); }); });