From 5ca8b3f6a163a38319b3d374715fd7188fc64137 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 9 Sep 2016 20:41:34 +0200 Subject: [PATCH] Always select matching result in autocomplete (fix #357) --- umap/static/umap/js/autocomplete.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/autocomplete.js b/umap/static/umap/js/autocomplete.js index 252c2c7b..44cafc05 100644 --- a/umap/static/umap/js/autocomplete.js +++ b/umap/static/umap/js/autocomplete.js @@ -282,8 +282,10 @@ L.S.AutoComplete.BaseSelect = L.S.AutoComplete.extend({ var results = [], self = this, count = 0; + val = val.toLowerCase(); 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)); count++; }