mousemke / flounder

Style-able dropdown replacement for native dropdowns
MIT License
9 stars 10 forks source link

[Performance] “addSelectKeyListener” should not be called when search is enabled #180

Closed conor-cafferkey-sociomantic closed 6 years ago

conor-cafferkey-sociomantic commented 6 years ago

Currently

addSelectKeyListener() gets called every time the dropdown opens (toggleOpen). It adds an event listener to the native <select> then focuses the the select.

Problem

This doesn’t make sense when search is enabled since we call focus() on the searchbox right after. (Focus changes are expensive when we have a very large dataset.)

Wanted

Don’t call addSelectKeyListener() when this.search is true.

conor-cafferkey-sociomantic commented 6 years ago

Probably also a good idea to move the focus() call out of addSelectKeyListener(). I think it’s an unexpected action for a method with that name to take.