You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to test PointerEvents that had been converted from MouseEvents. The pointerEnter pointerLeave don't work the same as the mouseEnter mouseLeave in testing library, but works fine in the browser.
What happened:
When I use fireEvent.pointerEnter in my test, my React component's onPonterEnter handler is not hit.
It's highly confusing that firing pointerEnter doesn't cause react onPointerEnter to fire.
Suggested solution:
In #588mouseEnter/mouseLeave had special handlers added to deal with the fact that React doesn't attach the native event and instead uses mouseOver / mouseOut. I think the same fix should be made for pointerEnter / pointerLeave
You wan work around this by firing pointerOver / pointerOut, but this is not ideal, as it requires the user to understand React's event model.
The text was updated successfully, but these errors were encountered:
In #588 mouseEnter/mouseLeave had special handlers added to deal with the fact that React doesn't attach the native event and instead uses mouseOver / mouseOut. I think the same fix should be made for pointerEnter / pointerLeave
Tested it quickly with firing pointerOver instead of pointerEnter and it does indeed seem to fix it.
A pull request would be much appreciated. Adding tests similar to the ones in #588 would be a good starting points. If you can't get the fix to work then feel free to open a PR with the test only. That would already help us a lot.
Closed in #784. We also uncovered another bug related got gotpointercapture and lostpointercaputre which got fixed with #786. @testing-library/react@^11.0.4 should have considerably better support for testing event handlers.
@testing-library/react
version: 11.0.2Relevant code or config:
https://codesandbox.io/s/react-testing-library-demo-forked-fkjt7?file=/src/__tests__/HoverTest.test.js
https://codesandbox.io/s/react-testing-library-demo-forked-fkjt7?file=/src/HoverTest.js
What you did:
I am trying to test PointerEvents that had been converted from MouseEvents. The pointerEnter pointerLeave don't work the same as the mouseEnter mouseLeave in testing library, but works fine in the browser.
What happened:
When I use
fireEvent.pointerEnter
in my test, my React component'sonPonterEnter
handler is not hit.Reproduction:
https://codesandbox.io/s/react-testing-library-demo-forked-fkjt7?file=/src/__tests__/HoverTest.test.js
Problem description:
It's highly confusing that firing
pointerEnter
doesn't cause reactonPointerEnter
to fire.Suggested solution:
In #588
mouseEnter
/mouseLeave
had special handlers added to deal with the fact that React doesn't attach the native event and instead usesmouseOver
/mouseOut
. I think the same fix should be made forpointerEnter
/pointerLeave
You wan work around this by firing
pointerOver
/pointerOut
, but this is not ideal, as it requires the user to understand React's event model.The text was updated successfully, but these errors were encountered: