-
-
Notifications
You must be signed in to change notification settings - Fork 6k
A bug in Android WebView triggers two clicks at once. #1227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… calls L.DomEvent.stop(event) on the second if two clicks are triggered within 400ms of each other. Double click is unaffected however. There are other workarounds that focus on _fireMouseEvent(), however I had to resolve it at the click event level as my map, markers, controls, were all affected.
| @@ -41,6 +41,13 @@ L.DomEvent = { | |||
|
|
|||
| obj.addEventListener(newType, handler, false); | |||
|
|
|||
| } else if (type === 'click') { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you only do this for Android if it's not relevant for other browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good point. I've implemented and pushed a check for the Android UA so we're not affecting anybody else. From what I've read this bug seems to affect any and all Android WebViews at this point
Previously it was blocking when an element had multiple click listeners because those events were fired rapidly. Since Android fires its second click at approximately 300ms after the first we do a check to make sure that at least 100ms has elapsed but not more than 400ms.
|
Good job @jerel, it seems to work perfectly for me. I had this problem and was looking for a way to fix it. Your solution works! Now, I only have a remaining problem with popup. I think it has to do with that click event firing twice. I have a popup with a image inside. When clicking on the image inside the popup, it launch another activity in my android app. But when the popup is outside the screen, the map pans to show it but there seems to be another click fired and that launch the activity automatically. Here's a video attached to show what i mean. Any idea what cause this? http://dl.dropbox.com/u/26198358/VIDEO0018.3gp Thank you guys! |
|
@HooliganQC I've experimented here and don't see that behavior. Can you replace the image with a non image link of the same size and see if it still happens? It could possibly be caused by a pause between events that's caused by the image loading. Other than that the only suggestion I have is to do some console.logs in the event handler and see what type of events are being triggered and by what. Doing an e.timeStamp will tell you what times they are being triggered |
|
He jerel, thanks for the fix! However the patch does not fix the bug on a Galaxy Nexus 4.2 Jelly Bean within a WebView. I have to use buttons that call the zoomIn() and zoomOut() methods in the mean time. I wish I could contribute a fix for this but I am not fluent in JavaScript. If you need a tester just gives a shout. Cheers! |
|
skunkfu2, what behavior are you seeing? What do you expect to happen and what happens instead and when? FWIW I'm running it on a device with Android 4.2.1 using a WebView that works fine |
|
Hey jerel, Before applying the patch, and having zoomControl set to true, when touching either zoom in or zoom out buttons, it does zoom either in or out but with the whole double tapping bug, and the tiles of the custom map I'm using actually overlaps on its edges depending on the zoom level. This happens straight away when I touch on the zoom buttons. After applying the patch, the buttons do not work at all. If needed, I can upload the test .apk file I'm currently using for my app, as well as the source. I can confirm that I'm using Android v4.2.1 on the Galaxy Nexus, and that it works fine on a HTC Desire Android v2.3.7 test device. Cheers bud. |
|
Okay scratch that, the fix works for me in conjunction with the CSS fix for the bug here: #161 I can't explain that one. Only problem with using the CSS fix is a considerable performance drop. Can't win them all! Cheers. |
A bug in Android WebView triggers two clicks at once.
|
Thanks for the pull! Cleaned it up a bit, please check if it still works. |
|
Hi, since i update my library to 0.5 i have this problem on Microsoft Surface with IE10 ... any ideas ? BR, |
|
@mfk please open a separate bug and post some more details. |
|
I'm using the latest LL build as of 2/21/13 (Leaflet-Leaflet-5558987) and I still see this bug in Android 4.1.1 WebView. It happens when I click the layer button, it right away selects another layer. A little annoying. I can see it also happen when I click a marker, but it doesn't make the popup flicker. |
|
Same problem here. I'm using this leaflet version: https://gist.github.com/bedspax/5480985 The popup sometimes blinks, sometimes disapperas, sometimes just stays. Here the video: http://cl.ly/143X2M3C1318 (Android 4.2.2, apk build) – Is this behavior OK? |
|
You should download the master version here https://github.com/Leaflet/Leaflet/archive/master.zip and include the files in the |
|
Thanks @mourner now works like a charm |
Was introduced in 8b742a0 to fix* Leaflet#1694, caused by Leaflet#1201. As we already removed related (Leaflet#1227) workarounds in Leaflet#7013, so this is just continuation.
This patch calls L.DomEvent.stop(event) on the second if two clicks are triggered within 400ms
of each other. Double click is unaffected however.
There are other workarounds that focus on _fireMouseEvent(), however I had to
resolve it at the click event level as my map, markers, controls, were all
affected.