Skip to content

Commit 686e015

Browse files
alpha0010actions-userj-piaseckim-bert
authored
Mocks: fix button content missing (#4048)
## Description <!-- Description and motivation for this PR. Include 'Fixes #<number>' if this is fixing some issue. --> Lacking button content in the provided mocks makes it impossible to write tests such as "is the button with 'foo' rendered" or "press the button with 'bar'". ## Test plan <!-- Describe how did you test this change here. --> ```tsx import {fireEvent, render} from '@testing-library/react-native'; import {Text} from 'react-native'; import {RectButton} from 'react-native-gesture-handler'; test('Trigger press by text', () => { const onPress = jest.fn(); const {getByText} = render( <RectButton onPress={onPress}> <Text>Press Me</Text> </RectButton>, ); fireEvent.press(getByText('Press Me')); expect(onPress).toHaveBeenCalled(); }); ``` --------- Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com> Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
1 parent 25b88db commit 686e015

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/react-native-gesture-handler/apple/RNGestureHandlerManager.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,14 @@ - (void)registerViewWithGestureRecognizerAttachedIfNeeded:(RNGHUIView *)childVie
244244
RNGHUIView *touchHandlerView = childView;
245245

246246
#if !TARGET_OS_OSX
247+
Class fullWindowOverlayContainerClass = NSClassFromString(@"RNSFullWindowOverlayContainer");
248+
247249
if ([[childView reactViewController] isKindOfClass:[RCTFabricModalHostViewController class]]) {
248250
touchHandlerView = [childView reactViewController].view;
249251
} else {
250-
while (touchHandlerView != nil && ![touchHandlerView isKindOfClass:[RCTSurfaceView class]]) {
252+
while (
253+
touchHandlerView != nil && ![touchHandlerView isKindOfClass:[RCTSurfaceView class]] &&
254+
(fullWindowOverlayContainerClass == nil || ![touchHandlerView isKindOfClass:fullWindowOverlayContainerClass])) {
251255
touchHandlerView = touchHandlerView.superview;
252256
}
253257
}

packages/react-native-gesture-handler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-gesture-handler",
3-
"version": "2.29.0",
3+
"version": "2.30.1",
44
"description": "Declarative API exposing native platform touch and gesture system to React Native",
55
"scripts": {
66
"test": "jest",

packages/react-native-gesture-handler/src/mocks/mocks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const LongPressGestureHandler = View;
3131
const PinchGestureHandler = View;
3232
const RotationGestureHandler = View;
3333
const FlingGestureHandler = View;
34-
export const RawButton = ({ enabled, ...rest }: any) => (
34+
export const RawButton = ({ enabled, children, ...rest }: any) => (
3535
<TouchableNativeFeedback disabled={enabled === false} {...rest}>
36-
<View />
36+
{children ?? <View />}
3737
</TouchableNativeFeedback>
3838
);
3939
export const BaseButton = RawButton;

0 commit comments

Comments
 (0)