Setting pointerEvents to "box-none" prevents triggering onTouch* and onLayout events on the element
See original GitHub issueDescribe 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 https://github.com/callstack/react-native-testing-library/pull/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
- Press the “Press me” text in the Expo Snack to observe the expected behavior.
- Clone the reproduction case, specifically the
pointerevents-box-none-and-ontouchevents
branch. npm install
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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Is there a way in which I can ignore touch events on Text in ...
If anyone is looking for the solution in normal React (not React Native), you can simply set the css to pointer-events: none for...
Read more >pointer-events - CSS: Cascading Style Sheets - MDN Web Docs
The pointer-events CSS property sets under what circumstances (if any) a particular graphic element can become the target of pointer events.
Read more >View - React Native
'none' : The View is never the target of touch events. 'box-none' : The View is never the target of touch events but...
Read more >Tumult Hype Documentation
Tumult Hype affords ways to trigger actions in response to mouse events such as clicks, ... By default, all Hype elements have pointer...
Read more >Pointer Events - W3C
While Pointer Events are sourced from a variety of input devices, they are not defined as being generated from some other set of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I opened https://github.com/callstack/react-native-testing-library/pull/906 for consideration to resolve this issue.
No, I do not believe so. The failing test case I provided for this issue originates from the WordPress Gutenberg project, which utilized
onTouch*
alongside of React Native0.61.5
at the time. I do not believe React Native0.61.5
leveraged the Fabric renderer.👍🏻 Great.