nfhipona / AutoCompleteTextField

TextField with smart suggestion for email inputs
http://nfhipona.github.io/AutoCompleteTextField/
MIT License
65 stars 13 forks source link

Filter datasource array from smallest string to biggest #18

Closed lfarah closed 8 years ago

lfarah commented 8 years ago

By doing that, we are always autocompleting the smallest possible option, avoiding errors in compound city names, for example.

My case

User wants to type "Salvador" (city in Brazil)

My DataSource array:

["são Paulo", "salvador do Sul", "macapa", "salvador"]

Problem:

Salvador do sul is autocompleted instead of Salvador because it goes first in the array, and since Salvador has less characters, it will never autocomplete.

Solution

always filter datasource from the smallest string to the biggest, so every single string will have the chance to be autocompleted

nfhipona commented 8 years ago

added fix

lfarah commented 8 years ago

Thanks!

carlbrusell commented 8 years ago

thanks