diff --git a/client/view/controls/autocomplete.js b/client/view/controls/autocomplete.js index 48056e72..1106eb52 100644 --- a/client/view/controls/autocomplete.js +++ b/client/view/controls/autocomplete.js @@ -8,18 +8,26 @@ class AutocompleteControl extends BaseControl { this.setupAwesomplete(); } - setupAwesomplete() { + async setupAwesomplete() { this.awesomplete = new Awesomplete(this.input, { minChars: 0, maxItems: 99 }); + this.list = await this.getList(); + // rebuild the list on input - this.input.addEventListener('input', async (event) => { - let list = await this.getList(); - this.awesomplete.list = list; + this.input.addEventListener('input', (event) => { + this.awesomplete.list = this.list; }); } + + validate(value) { + if (this.list.includes(value)) { + return value; + } + return false; + } }; module.exports = AutocompleteControl; \ No newline at end of file