React: React 15-rc.1 regression: onTouchTap not working

Created on 8 Mar 2016  路  11Comments  路  Source: facebook/react

onTouchTap stops working in React 15. I've prepared this reduction.

The only difference between pane A and pane B is which version of React is used. If you open it on a touchscreen device (or in DevTools with emulation on), you'll see that onTouchTap worked in React 14, but ceases to work in React 15.

Most helpful comment

Thanks guys.

For some reason, I remembered touch events not being detected without TapEventPlugin being installed. I just tested it, and that is no longer the case. Since Chrome and Safari have both removed their tap delays for mobile pages, it's probably time to stop using TapEventPlugin and just us the onClick event.

As for gestures, I'm considering building higher-order-components to detect them, and I certainly won't be quite about it if it happens. :wink:

All 11 comments

Someone proposed that onTouchTap might now be integrated. It's not

Finally! Thanks for the heads up.
After banging on for 2 days and trying to fix on my side, thinking everything is wrong on my setup, commented here yesterday.

I thought its MaterialUI. Will give it a try on React 14.

I have now tested it with "react": "^0.14.7" and "react-dom": "^0.14.7". It works fine, without even the touch emulator.

This is not a regression.

If you look at the history of TapEventPlugin in the React codebase you will see that it was affected by one of the recent refactorings (this is internal code and we make no guarantees about the API stability). Specifically, 4a465fbd9a99815e9a0eb8b14af0c0423d9e8552 and f470cb88f88b4667419f170fcc7971dad4298494 changed some of the arguments that were being passed.

Since react-tap-event-plugin is effectively a fork of TapEventPlugin, it needs to incorporate upstream changes to be compatible with any next release. I sent a PR to react-tap-event-plugin that mirrors these changes. In my testing this makes it compatible with React 15 RC2, and I would expect it to also be compatible with the final 15 because that code hasn鈥檛 changed since. You can find that PR as https://github.com/zilverline/react-tap-event-plugin/pull/65.

I鈥檓 closing this but please let us know if you have any other issues. Cheers!

I didn't realize that TapEventPlugin was still maintained internally.

What's the plan for unifying the two? React should support touch events out-of-the-box. If for some reason that's out-of-scope, can Facebook use/maintain the npm package, so we don't have two parallel copies of the same code?

I don't think it's maintained per se. It's just that there was an internal refactoring that changed the argument order, and @soprano went through all matching call sites, changing them there, and it happened to include TapEventPlugin. We make no guarantees about it not being broken. I think we should remove it from the core source code. But yeah, this means that its maintainers will need to track changes to internal APIs. We don't have a better solution right now. Eventually we might expose event system officially as well as DOM configs but if addons taught us anything, it's that anything we expose creates a huge maintenance burden down the road which creates significant delays in development of React itself. So please excuse us that we don't have a good story around this right now. We are happy to discuss handling taps in a separate issue though so feel free to file it! Thanks.

@gaearon is correct. To add to his comment, the plan is to rip it out of the core repository and have this handled in user land, as per: https://github.com/facebook/react/issues/436#issuecomment-178268985

Thanks guys.

For some reason, I remembered touch events not being detected without TapEventPlugin being installed. I just tested it, and that is no longer the case. Since Chrome and Safari have both removed their tap delays for mobile pages, it's probably time to stop using TapEventPlugin and just us the onClick event.

As for gestures, I'm considering building higher-order-components to detect them, and I certainly won't be quite about it if it happens. :wink:

Since Chrome and Safari have both removed their tap delays for mobile pages, it's probably time to stop using TapEventPlugin and just use the onClick event.

:+1:

@appsforartists

Since Chrome and Safari have both removed their tap delays for mobile pages

But how long will it take for these changes to hit iOS Safari? The latest iOS 9.3.1 doesn't have fast tap response.

Since Chrome and Safari have both removed their tap delays for mobile pages, it's probably time to stop using TapEventPlugin and just use the onClick event.

Totally agree @appsforartists.

However, while onClick is working fine (meaning; without 350ms delay) in modern iOS Safari, it does not work with Cordova. Anyone that has encountered the same issue, and know why that is the case?

Was this page helpful?
0 / 5 - 0 ratings