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
Attaching of onclick handler causes unexpected highlighting in Mobile Safari #238
@yungsters's recent commit 4deb0d6 makes onClick work in Mobile Safari by attaching an empty onclick handler on touchstart. However, this causes subtly different behavior from DOM events without React. Consider the JSX:
When an image is tapped, the onclick handler is attached to the image and so when the browser draws the light gray touch highlight, only the image is highlighted.
Does it sound like addressing this at the rendering layer is a reasonable approach? Whenever a React instance has an onClick handler, we can render its markup as <div onclick="function(){}" />.
Apart from its ugliness, I see one problem with this approach: if my guess is right and
the Apple engineers have in fact disabled click event delegation because of memory
considerations, this workaround will create new memory problems. Lots of them if you
have lots of divs that must become clickable.
But that can’t be helped. Event delegation simply must work for the click event, and if
we have to brute-force it at the expense of memory that’s just too bad for Safari iPhone.
An alternative is to force cursor: pointer on Mobile Safari, since you can't see the cursor no one should care, it only has to exist for that element with a click-handler and it should keep us away from the issue above? I think? (It does have to play nice with style though, which might not be trivial?)
Activity
jordwalke commentedon Jul 29, 2013
Does it sound like addressing this at the rendering layer is a reasonable approach? Whenever a React instance has an
onClickhandler, we can render its markup as<div onclick="function(){}" />.sophiebits commentedon Jul 29, 2013
Yes, I think that makes sense.
yungsters commentedon Dec 23, 2013
@jordwalke Actually, I think an empty
onclick=""would work in this case.syranide commentedon May 27, 2014
http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
An alternative is to force
cursor: pointeron Mobile Safari, since you can't see the cursor no one should care, it only has to exist for that element with a click-handler and it should keep us away from the issue above? I think? (It does have to play nice with style though, which might not be trivial?)Merge pull request react#238 from sompylasar/fix-typo-recursivelyinit…
Merge pull request react#238 from sompylasar/fix-typo-recursivelyinit…