ftlabs / fastclick

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

<select> in PWA doesn't fire on Android #609

Open erbarratt opened 2 years ago

erbarratt commented 2 years ago

Select that fire correctly in Chrome on Android, don't fire when in the PWA of that same site.

FastClick is the only plugin, everything else is vanilla JS.

It only doesn't fire on select's that ALSO have an eventListener attached to them (usually change) OR that are checked inside the the eventListener of another element.

For example, I have a "Country" select with option val=0 being "Please Select". The submit button for that form checks to see if that select's val is still 0, and if so marks it with some CSS. Inside a PWA, this select box doesn't open.

If I duplicate the same form but remove the click eventListener on the submit button, the select DOES fire.

This is all bypassed by "needsclick" class, but I found it interesting there was this distinction.

Now, for every page before calling FastClick, I run:

let selects = document.querySelectorAll('select');
for(let i = 0; i < selects.length; i++){
    selects[i].classList.add('needsclick');
}