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

fireEvent cannot be triggered on elements with pointer events box only #1387

Closed
pierrezimmermannbam opened this issue Apr 13, 2023 · 1 comment · Fixed by #1395
Closed

fireEvent cannot be triggered on elements with pointer events box only #1387

pierrezimmermannbam opened this issue Apr 13, 2023 · 1 comment · Fixed by #1395

Comments

@pierrezimmermannbam
Copy link
Collaborator

pierrezimmermannbam commented Apr 13, 2023

Describe the bug

The following test will fail

test('works on pressable with pointer event to box-only', () => {
  const mockOnPress = jest.fn();

  const screen = render(
    <Pressable
      onPress={mockOnPress}
      pointerEvents="box-only"
      testID="pressable"
    />
  );

  fireEvent.press(screen.getByTestId('pressable'));
  expect(mockOnPress).toHaveBeenCalled();
});

What happens is that the pointer-events condition checks that there is not box-only on the parent but here the parent is the composite element and it has box-only so the element is considered to be disabled.

Expected behavior

The test should pass

Steps to Reproduce

Versions

I've written the test in the up to date repo of RNTL

I think this can be fixed if we look at the host parent instead of the direct parent using the method getHostParent. I'll try to submit a PR soon for this. I have made a version of the function that checks pointer-events in #1386 which could be used by fireEvent I think

@mdjastrzebski
Copy link
Member

This issue has been resolved in v12.1.2 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants