From 089efbe57ef125dc98276ba66c85e614bc8ecb28 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Fri, 26 Feb 2021 14:09:41 +0200 Subject: [PATCH] Add support for multiple menu locations --- keepassxc-browser/content/autocomplete.js | 10 ++++------ keepassxc-browser/content/credential-autocomplete.js | 5 ++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/keepassxc-browser/content/autocomplete.js b/keepassxc-browser/content/autocomplete.js index e31d267..cea4e74 100644 --- a/keepassxc-browser/content/autocomplete.js +++ b/keepassxc-browser/content/autocomplete.js @@ -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) { diff --git a/keepassxc-browser/content/credential-autocomplete.js b/keepassxc-browser/content/credential-autocomplete.js index d62d0df..7c86a5d 100644 --- a/keepassxc-browser/content/credential-autocomplete.js +++ b/keepassxc-browser/content/credential-autocomplete.js @@ -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) {