Mobius1 / Selectr

A lightweight, vanilla javascript select box replacement. No dependencies.
MIT License
313 stars 77 forks source link

Minor UX issue when clicking outside the container #132

Open martin9348 opened 5 years ago

martin9348 commented 5 years ago

If the dropdown is open (options list being shown), when clicking outside the container, the focus on the element that was clicked is lost.

In other words, if I click the select box to select an option then change my mind and click another field in the form (while the dropdown/options list is shown), the focus in that new field is lost.

Currently, in the code it's doing the following: document.addEventListener("click", this.events.dismiss);

If I replace with the following, it seems to fix the issue: document.addEventListener("mousedown", this.events.dismiss);

Any thoughts?