mercadolibre / chico

A collection of easy-to-use UI components.
http://chico.mercadolibre.com
MIT License
342 stars 91 forks source link

When using autofocus in autocomplete, the component is not initialized #1235

Closed marcoscaceres26 closed 9 years ago

marcoscaceres26 commented 9 years ago

The autocomplete is initialized when the user focus at the trigger input. https://github.com/mercadolibre/chico/blob/master/src/shared/js/Autocomplete.js#L198

However, if autofocus is used, the js listened es added after the input is focused, consequently the component is never initialized until the user manually leaves the the input and makes focus it again.

The suggested solution is to verify if autofocus is present, and initialize at automatically if so.

if (this.$trigger.prop('autofocus')) {
    this._turnOn();
}