ftlabs / fastclick

Polyfill to remove click delays on browsers with touch UIs
MIT License
18.66k stars 3.23k forks source link

Android Chrome Select Box Issue #159

Closed JayCarney closed 10 years ago

JayCarney commented 11 years ago

with FastClick running select boxes require a deliberate touch, even with the needsclick class. Without FastClick they perform far better and open on a quick tap

eremzeit commented 11 years ago

Which version of chrome are you using?

JayCarney commented 11 years ago

v29.0.1547.72 have tested with the latest beta as well and issue still exists

eremzeit commented 11 years ago

What kind of times are you getting on the basic use page?

http://ftlabs.github.io/fastclick/examples/layer.html

I have v29.0.1547.72 and am getting ~8ms without fastclick, ~0ms with fastclick.

JayCarney commented 11 years ago

without 20ms, with 0

JayCarney commented 11 years ago

The select box on the demo page plays up for me as well if I try to tap it or hold on it for longer than a normal "click": http://ftlabs.github.io/fastclick/examples/input.html

daniellee commented 10 years ago

Just spent half a day on this issue. As has been pointed out before, it depends on how fast you tap. A select is a tag that needs focus and in the onTouchEnd handler there is some code that returns early if a touch takes longer than 100ms as focus will be triggered anyway. So instead of sending the synthetic click then the native click is used.

If the touch is quicker than 100ms for a tag that needs focus (the select) then the function

I don't understand the logic here. It just sets the focus on the select and does not open the select box. Is this a special case for iOS that doesn't work on Android?

In this part of the function, if you change the 100ms in the if statement:

(event.timeStamp - trackingClickStart) > 100

to a smaller value like 50 then it works much better for fast taps. However, I don't know if that is the best solution as it's then not really a fast click anymore. On Monday we will be testing on loads of devices (iphones, ipads, androids from 2.2 upwards and Windows Phone) so hopefully we can find a better solution and I can submit a pull request then.

BTW, the Chrome version I'm testing on is 29.0.1547.72 on a HTC One (Android version 4.2.2) (getting the same issue on Samsung and Nexus 4 too)

daniellee commented 10 years ago

I noticed that adding the needsclick class to a select element does not solve this problem. The needsFocus logic in the TouchEnd event handler comes before the logic that checks for the needsclick class.

Maybe this is something that should be changed? If I set the needsclick class on an element then I don't expect fastclick to try and set focus on the element either.