ftlabs / fastclick

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

Click event not firing after set focus to <input> #176

Closed apostololeg closed 10 years ago

apostololeg commented 11 years ago

test page – http://skymorph.in/t/fastclick

I tried to understand problem, but only can I find that click event not firing due to the fact that return prevent all subsequent actions. Without this return it seems everything is working well.

matthew-andrews commented 10 years ago

Hi @truerenton, I had a look at your example. It seems to work correctly.

Would you be able to help me understand what you're expecting it to do and how that is different from what it actually does? Also could you tell me which browsers / devices you're having problems with?

I'm using an iPhone 4S with iOS 7.0.4.

apostololeg commented 10 years ago

Probably, you do a longpress, but when tap is short(it seems here) – backgorund don't goes white. Take a look this video https://dl.dropboxusercontent.com/u/7624831/Trash/2013-11-20_1548.swf and will become clear.

arikon commented 10 years ago

@matthew-andrews Could you have a look at @truerenton's example video?

fabianfetik commented 10 years ago

@matthew-andrews I can confirm this issue and it exists in FastClick version 0.6.7 as well as version 0.6.11. Everything is working fine if you hold down a little, but whenever you just tap it doesn't. Present in at least Android 4.1.2, 4.2.2, 4.3 and 4.4 across various devices (Nexus 10, HTC Desire HD, HTC One X)

Hopefully the list of devices and versions helps

matthew-andrews commented 10 years ago

OK. I can reproduce the bug. You said in the original description that

'Without this return it seems everything is working well'

Which return did you remove, was it this one? https://github.com/ftlabs/fastclick/blob/master/lib/fastclick.js#L561

matthew-andrews commented 10 years ago

Right I think I know what the problem is. Normally in browsers when you tap in an input field the events are:

screen shot 2013-12-12 at 13 58 14 (Note in the console logs I've used te as shorthand to mean touchend)

FastClick eliminates the 300ms delay in this case by manually triggering a focus event when touchend is detected however we don't trigger a click event. So with FastClick the events look like this:

Therefore I think the fix should just be to add a synthetic click after focusing on element so that FastClick events are consistent with the browser. I think this should be harmless - though I would like a second opinion from the other Matt. @mattcg what do you think?

Thanks for bringing this issue to our attention, @truerenton.

apostololeg commented 10 years ago

thankee, @matthew-andrews !

matthew-andrews commented 10 years ago

This should now be available in v0.6.12, sorry for the delay.