Skip to content

MobileSafariClickEventPlugin requires touch events to be initialized #1169

Description

@Simek

Activity

  1. syranide commented on Feb 24, 2014

    @syranide
    Contributor

    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.

  2. MattKunze commented on Feb 24, 2014

    @MattKunze

    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.

  3. syranide commented on Feb 24, 2014

    @syranide
    Contributor

    @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.

  4. sophiebits commented on Feb 24, 2014

    @sophiebits
    Collaborator
  5. MattKunze commented on Feb 24, 2014

    @MattKunze

    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

  6. Simek commented on Feb 24, 2014

    @Simek
    ContributorAuthor

    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.

  7. MattKunze commented on Feb 24, 2014

    @MattKunze

    Adding

        componentDidMount: function() {
          this.getDOMNode().onclick = function() {}
        }

    to the component is a workaround. It seems like the plugin is not working at the moment

  8. mietek commented on Mar 23, 2014

    @mietek

    This is still not working in 0.10.0, and is actually a duplicate of #134.

    Adding cursor: pointer to elements which are intended to be clickable is still the least-offensive workaround.

  9. changed the title [-]Click event doesn't work on iOS on certain situation[/-] [+]MobileSafariClickEventPlugin requires touch events to be initialized[/+] on Mar 26, 2014
  10. sophiebits commented on Apr 16, 2014

    @sophiebits
    Collaborator

    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.

  11. added a commit that references this issue on Apr 29, 2014
  12. 34 remaining items

  13. ustun commented on Jan 24, 2016

    @ustun

    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?

  14. sophiebits commented on Feb 26, 2016

    @sophiebits
    Collaborator

    @ustun Not on this specifically, but we have no evidence that it's a hotspot.

  15. hansthinhle commented on Mar 24, 2016

    @hansthinhle

    It's fixed in 0.14 beta and will be in the final 0.14 as well.

    @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.

  16. sophiebits commented on Mar 24, 2016

    @sophiebits
    Collaborator

    I don't know of any changes in 15.0 that would have affected this.

  17. brunogarcia commented on Jul 6, 2016

    @brunogarcia

    @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

  18. sophiebits commented on Jul 6, 2016

    @sophiebits
    Collaborator

    @brunogarcia Can you post a jsfiddle or jsbin with this?

  19. brunogarcia commented on Jul 7, 2016

    @brunogarcia

    @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.

  20. easga commented on Aug 12, 2016

    @easga

    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.

  21. tiaaaa123 commented on Sep 21, 2016

    @tiaaaa123

    I am having the same issue in react 15.0.1

  22. sophiebits commented on Sep 21, 2016

    @sophiebits
    Collaborator

    @easga @tiaaaa123 If one of you can find a simple repro case (jsbin or jsfiddle), please post it and we can dig in.

  23. easga commented on Sep 22, 2016

    @easga

    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!

  24. amiut commented on Sep 13, 2021

    @amiut

    If the problem still exists , maybe overlaying a position absolute a tag that wraps your element and adding the click event to this a tag will help.

  25. locked and limited conversation to collaborators on Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions