ftlabs / fastclick

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

FastClick and Selectize.js on iOS 7, can't select from dropdown #265

Open kinergy opened 10 years ago

kinergy commented 10 years ago

The selectize.js library doesn't work correctly with FastClick enabled on my iPhone with iOS 7.1.1. Selectize is an html select element replacement like Chosen and Select2. When taping the input, the the dropdown opens, however, when taping one of the options in the pulldown, the dropdown simply closes without selecting the option.

Any thoughts on things I should check in FastClick or Selectize to debug this? I know that when I deactivate FastClick, the Selectize dropdown works...

Thanks!

kinergy commented 10 years ago

I also tried using needsclick but this didn't help.

jpcamara commented 10 years ago

You may want to look at this issue - #103. It fixed a similar issue for me with select2

biesbjerg commented 10 years ago

I've created a plugin for selectize that fixed the issue for me by adding 'needsclick'-class to the appropiate elements.

https://gist.github.com/biesbjerg/bb28ba80862d57306a0e

matthew-andrews commented 10 years ago

I've made a reduced test case here: http://jsbin.com/miluw/2/edit

And taken a quick look through the selectize source code and identified the incompatibility. It's related to #103 - but I suspect it would need more to fix it. The library seems to rely on both mouse up and mouse down events...

When I closed #103 I personally felt that it would be better if libraries didn't rely on input device specific events but what I had forgotten was that touch screen devices still emit mouse up / mouse down events. I think we should match the native click of the browser (including all the events surrounding the click, eg focus)

Therefore I think my response to #103 was wrong - but we need to do more than that PR suggested and we should synthesise both mouse ups and mouse downs. Anyway I'll reopen #103.