Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's annoying that Select2 and Chosen don't create a 'close menu' transparent overlay over the rest of the page, so the menu closes if you click outside of it.


It closes when I click outside of it.


Ah, it does on the computer. On the iPad and iPhone, it does not for some reason.


It's a one line fix, just the developer listening for a mousedown and not a touchstart event.

https://github.com/ivaynberg/select2/issues/77


Ah, that'll do it. Listening for a click event should work for both, no?


A mouse is not a finger ;)


True, but they can both generate click events; I've got widgets that listen for clicks and work fine on mobile Safari.


A click event would be triggered after the mouseup event, and you to open the dropdown on mousedown event so that you can do all the selection in one click.

I just tried binding .open() to the mousedown event and .close() to the mouseup event and it seems to work for that use case, but it still has to know to behave in the other way (open on mousedown, but don't always close on mouseup).


Oh right... I somehow forgot that pulldown menus can be used as their name implies, by clicking and holding down the mouse to open the menu, and release to make your selection; I've gotten so used to clicking to open, having them stay open, and then clicking again to make my selection (at least since Apple first enabled that feature in System 7). All of a sudden, I'm much less proud of my home-rolled pulldown-menu implementation I've been using.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: