Skip to content

Setting pointerEvents to "box-none" prevents triggering onTouch* and onLayout events on the element #897

Closed
@dcalhoun

Description

@dcalhoun

Describe the bug

Setting pointerEvents: 'box-none' on a View prohibits triggering onTouch* or onLayout events on the View. This behavior differs from React Native itself. This Expo Snack showcases that pressing the child Pressable of a <View pointerEvents="box-none" /> still triggers the onTouchStart and onTouchEnd events. This change in behavior, which appears to differ from React Native, began in with 7.2.0 due to changes in #655.

Expected behavior

Invoking fireEvent.trigger(viewWithPointerEventsBoxNone, "onTouchStart") results in triggering the View's onTouchStart handler.

Similarly, invoking fireEvent.trigger(viewWithPointerEventsBoxNone, "onLayout") results in triggering the View's onLayout handler.

Steps to Reproduce

  1. Press the "Press me" text in the Expo Snack to observe the expected behavior.
  2. Clone the reproduction case, specifically the pointerevents-box-none-and-ontouchevents branch.
  3. npm install
  4. npm run test

Screenshots

n/a

Versions

  npmPackages:
    @testing-library/react-native: ^9.0.0 => 9.0.0
    react: 17.0.2 => 17.0.2
    react-native: 0.66.4 => 0.66.4
    react-test-renderer: 17.0.2 => 17.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions