Add support for multiple menu locations

This commit is contained in:
varjolintu 2021-02-26 14:09:41 +02:00
parent 80b3c5016d
commit 089efbe57e
2 changed files with 8 additions and 7 deletions

View file

@ -4,9 +4,9 @@ const MAX_AUTOCOMPLETE_NAME_LEN = 50;
class Autocomplete {
constructor() {
this.autocompleteList = [];
this.autoSubmit = false;
this.elements = [];
this.started = false;
this.index = -1;
this.input = undefined;
this.shadowRoot = undefined;
@ -35,19 +35,17 @@ class Autocomplete {
}
this.autoSubmit = autoSubmit;
this.input = input;
if (!this.started) {
input.addEventListener('click', ev => this.click(ev, this.input));
if (!this.autocompleteList.includes(input)) {
input.addEventListener('click', ev => this.click(ev, input));
input.addEventListener('keydown', ev => this.keyPress(ev));
input.setAttribute('autocomplete', 'off');
this.autocompleteList.push(input);
}
if (showListInstantly) {
this.showList(input);
}
this.started = true;
}
mouseOver(e, div, item) {

View file

@ -10,7 +10,10 @@ CredentialAutocomplete.prototype.click = async function(e, input) {
input.select();
}
this.showList(input);
const field = this.autocompleteList.find(a => a === input);
if (field) {
this.showList(field);
}
};
CredentialAutocomplete.prototype.itemClick = async function(e, item, input, uuid) {