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
{{ message }}
Repository navigation
MobileSafariClickEventPlugin requires touch events to be initialized #1169
There is no reference to pointer (not even cursor) in the React codebase, so I'm assuming this is some weird iOS bug, React might be able to work around it though.
My guess is that is an issue that has been around for quite a while (interesting timing that I ran into the same thing for a different context this morning):
@MattKunze We do try to fix things that can be fixed and it wouldn't surprise me if you can temporarily add a click-handler on touch and solve it like that.
changed the title [-]Click event doesn't work on iOS on certain situation[/-][+]MobileSafariClickEventPlugin requires touch events to be initialized[/+]on Mar 26, 2014
Ever since on-demand event listening was added, MobileSafariClickEventPlugin has been broken because touchstart isn't always listened to. cursor: pointer; is an okay workaround but we'll have to fix this for real somehow, probably by having onclick handlers turn into onclick="" markup.
We could probably do this only on iOS but I don't know if other browsers use similar heuristics. Hopefully this has minimal performance impact but we're planning to do some benchmarking soon and if this is significant we'll figure out a way to speed it up.
@spicyj Were you able to perform any benchmarks after this was merged?
@spicyj Hi, we've made more testing with Safari (iOS 9.3.2).
We've found that Safari on private browsing doesn't save data into LocalStore.
So, it's not a React bug.
Sorry for my mistake.
This has taken my day, i had a form which was handling onSubmit first. Form was refreshing on iphone 4 even though it was executing event.preventDefault().(every other device i tested works with no problem since the beginning) Then i tried everything which i ended replacing form with a div and making the button handling onClick. I am running (react": "^15.0.1"), including cursor pointer but click event never happens so i can not execute the function. I really do not know what is left for me to try. I would wholeheartedly appreciate if i could find a solution. thanks.
Activity
syranide commentedon Feb 24, 2014
There is no reference to
pointer(not evencursor) in the React codebase, so I'm assuming this is some weird iOS bug, React might be able to work around it though.MattKunze commentedon Feb 24, 2014
My guess is that is an issue that has been around for quite a while (interesting timing that I ran into the same thing for a different context this morning):
http://www.quirksmode.org/blog/archives/2010/10/click_event_del_1.html
http://stackoverflow.com/questions/7358781/tapping-on-label-in-mobile-safari
You'll see a bunch of workarounds that add empty handlers when the page loads to address this (
$('label').click(function() {});)Doesn't seem like React's problem to fix - either add 'cursor: pointer' or empty event handlers where it causes an issue.
syranide commentedon Feb 24, 2014
@MattKunze We do try to fix things that can be fixed and it wouldn't surprise me if you can temporarily add a click-handler on touch and solve it like that.
sophiebits commentedon Feb 24, 2014
Yes, we have https://github.com/facebook/react/blob/master/src/browser/eventPlugins/MobileSafariClickEventPlugin.js to fix this exact problem but it sounds like perhaps it's not working.
MattKunze commentedon Feb 24, 2014
Is that plug-in registered automatically, or do you have to do something to enable it?
I can confirm that the original jsfiddle posted above isn't working for me on iOS
Simek commentedon Feb 24, 2014
Digging through repository I found event plugin which seems to be related to similar bug:
https://github.com/facebook/react/blob/master/src/browser/eventPlugins/MobileSafariClickEventPlugin.js
But problem seems to be little wider because Chrome on iOS is also affected so this is an mobile webkit issue.
MattKunze commentedon Feb 24, 2014
Adding
to the component is a workaround. It seems like the plugin is not working at the moment
mietek commentedon Mar 23, 2014
This is still not working in 0.10.0, and is actually a duplicate of #134.
Adding
cursor: pointerto elements which are intended to be clickable is still the least-offensive workaround.[-]Click event doesn't work on iOS on certain situation[/-][+]MobileSafariClickEventPlugin requires touch events to be initialized[/+]sophiebits commentedon Apr 16, 2014
Ever since on-demand event listening was added, MobileSafariClickEventPlugin has been broken because touchstart isn't always listened to.
cursor: pointer;is an okay workaround but we'll have to fix this for real somehow, probably by having onclick handlers turn intoonclick=""markup.Make things clickable in iOS
34 remaining items
Workaround symbol click event trigger on iOS
ustun commentedon Jan 24, 2016
@spicyj Were you able to perform any benchmarks after this was merged?
sophiebits commentedon Feb 26, 2016
@ustun Not on this specifically, but we have no evidence that it's a hotspot.
hansthinhle commentedon Mar 24, 2016
@spicyj onClick is still not working on iOS in 0.14.7 but fixed in 15.0. And we sill get stuck in 0.14.7 I think.
sophiebits commentedon Mar 24, 2016
I don't know of any changes in 15.0 that would have affected this.
brunogarcia commentedon Jul 6, 2016
@spicyj I've tried with React 15.1.0 but still doesn't work in Safari 9.0.
By the way on Chrome 51.0.2 works perfectly.
Both tested into an iPad 9.1
sophiebits commentedon Jul 6, 2016
@brunogarcia Can you post a jsfiddle or jsbin with this?
brunogarcia commentedon Jul 7, 2016
@spicyj Hi, we've made more testing with Safari (iOS 9.3.2).
We've found that Safari on private browsing doesn't save data into LocalStore.
So, it's not a React bug.
Sorry for my mistake.
easga commentedon Aug 12, 2016
This has taken my day, i had a form which was handling onSubmit first. Form was refreshing on iphone 4 even though it was executing event.preventDefault().(every other device i tested works with no problem since the beginning) Then i tried everything which i ended replacing form with a div and making the button handling onClick. I am running (react": "^15.0.1"), including cursor pointer but click event never happens so i can not execute the function. I really do not know what is left for me to try. I would wholeheartedly appreciate if i could find a solution. thanks.
tiaaaa123 commentedon Sep 21, 2016
I am having the same issue in
react 15.0.1sophiebits commentedon Sep 21, 2016
@easga @tiaaaa123 If one of you can find a simple repro case (jsbin or jsfiddle), please post it and we can dig in.
easga commentedon Sep 22, 2016
Thanks. My customer was seeing this problem on iphone 4, but once i realized i could simulate that device and check the logs, i realized that my production js was having problems due the reason mentioned in this article (http://lukecod.es/2016/03/14/react-invariant-violation-minified-exception-ios8-webpack-babel/). Then i made it work. Sorry that i forgot to update it here, everything works great with React itself!
amiut commentedon Sep 13, 2021
If the problem still exists , maybe overlaying a position absolute
atag that wraps your element and adding the click event to thisatag will help.