Always select matching result in autocomplete (fix #357)

This commit is contained in:
Yohan Boniface 2016-09-09 20:41:34 +02:00
parent 805bca7a97
commit 5ca8b3f6a1

View file

@ -282,8 +282,10 @@ L.S.AutoComplete.BaseSelect = L.S.AutoComplete.extend({
var results = [], var results = [],
self = this, self = this,
count = 0; count = 0;
val = val.toLowerCase();
this.forEach(this.el, function (item) { this.forEach(this.el, function (item) {
if (item.innerHTML.toLowerCase().indexOf(val.toLowerCase()) !== -1 && !item.selected && count < self.options.maxResults) { var candidate = item.innerHTML.toLowerCase();
if (candidate === val || (candidate.indexOf(val) !== -1 && !item.selected && count < self.options.maxResults)) {
results.push(self.optionToResult(item)); results.push(self.optionToResult(item));
count++; count++;
} }