autocomplete: limit static metatags to 10 matches.
Prevents autocomplete menu from becoming excessively long when completing order: metatags.
This commit is contained in:
@@ -433,14 +433,10 @@ Autocomplete.static_metatags = {
|
|||||||
Autocomplete.static_metatag_source = function(term, resp, metatag) {
|
Autocomplete.static_metatag_source = function(term, resp, metatag) {
|
||||||
var sub_metatags = this.static_metatags[metatag];
|
var sub_metatags = this.static_metatags[metatag];
|
||||||
|
|
||||||
var regexp = new RegExp("^" + $.ui.autocomplete.escapeRegex(term), "i");
|
var matches = sub_metatags.filter(sub_metatag => sub_metatag.startsWith(term.toLowerCase()));
|
||||||
var matches = $.grep(sub_metatags, function (sub_metatag) {
|
matches = matches.map(sub_metatag => `${metatag}:${sub_metatag}`).sort().slice(0, 10);
|
||||||
return regexp.test(sub_metatag);
|
|
||||||
});
|
|
||||||
|
|
||||||
resp($.map(matches, function(sub_metatag) {
|
resp(matches);
|
||||||
return metatag + ":" + sub_metatag;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Autocomplete.user_source = function(term, resp, metatag) {
|
Autocomplete.user_source = function(term, resp, metatag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user