Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set default pointer events on web Surface #3908

Merged
merged 1 commit into from
Jun 28, 2023
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
2 changes: 2 additions & 0 deletions src/components/Surface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,11 @@ const Surface = forwardRef<View, Props>(
const isElevated = mode === 'elevated';

if (Platform.OS === 'web') {
const { pointerEvents = 'auto' } = props;
return (
<Animated.View
{...props}
pointerEvents={pointerEvents}
ref={ref}
testID={testID}
style={[
Expand Down
21 changes: 19 additions & 2 deletions src/components/__tests__/ListItem.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as React from 'react';
import { StyleSheet } from 'react-native';
import { Platform, StyleSheet } from 'react-native';
import { Text, View } from 'react-native';

import { render } from '@testing-library/react-native';
import { fireEvent, render } from '@testing-library/react-native';

import { red500 } from '../../styles/themes/v2/colors';
import Chip from '../Chip/Chip';
import IconButton from '../IconButton/IconButton';
import ListIcon from '../List/ListIcon';
import ListItem from '../List/ListItem';

Expand Down Expand Up @@ -110,3 +111,19 @@ it('renders with a description with typeof number', () => {

expect(tree).toMatchSnapshot();
});

it('calling onPress on ListItem right component', () => {
Platform.OS = 'web';
const onPress = jest.fn();

const { getByTestId } = render(
<ListItem
title="First Item"
description="Item description"
right={() => <IconButton icon="pencil" onPress={onPress} />}
/>
);

fireEvent(getByTestId('icon-button'), 'onPress');
expect(onPress).toHaveBeenCalledTimes(1);
});