From 25d9fd1c672ed9c11fda87a4730fe59088ef7129 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Fri, 2 Apr 2021 09:06:34 +0300 Subject: [PATCH 1/2] Fix autocomplete menu with keyboard --- keepassxc-browser/content/autocomplete.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/keepassxc-browser/content/autocomplete.js b/keepassxc-browser/content/autocomplete.js index cea4e74..6152315 100644 --- a/keepassxc-browser/content/autocomplete.js +++ b/keepassxc-browser/content/autocomplete.js @@ -171,11 +171,12 @@ class Autocomplete { } const items = this.getAllItems(); + const inputField = e.target; if (e.key === 'ArrowDown') { // If the list is not visible, show it if (items.length === 0) { this.index = -1; - this.showList(this.input); + this.showList(inputField); } else { // Activate next item ++this.index; @@ -185,7 +186,7 @@ class Autocomplete { --this.index; this.activateItem(items); } else if (e.key === 'Enter') { - if (this.input.value === '') { + if (inputField.value === '') { e.preventDefault(); } @@ -197,23 +198,23 @@ class Autocomplete { } } else if (e.key === 'Tab') { // Return if value is not in the list - if (this.input.value !== '' && !this.elements.some(c => c.value === this.input.value)) { + if (inputField.value !== '' && !this.elements.some(c => c.value === inputField.value)) { this.closeList(); return; } - this.index = this.elements.findIndex(c => c.value === this.input.value); + this.index = this.elements.findIndex(c => c.value === input.value); if (this.index >= 0) { - this.fillPassword(this.input.value, this.index, this.elements[this.index].uuid); + this.fillPassword(inputField.value, this.index, this.elements[this.index].uuid); } this.closeList(); } else if (e.key === 'Escape') { this.closeList(); - } else if ((e.key === 'Backspace' || e.key === 'Delete') && this.input.value === '') { + } else if ((e.key === 'Backspace' || e.key === 'Delete') && inputField.value === '') { // Show menu when input field has no value and backspace is pressed this.index = -1; - this.showList(this.input); + this.showList(inputField); } } From aa6b1df0ceda6b7a0da8c5f3311d8ab9579e903d Mon Sep 17 00:00:00 2001 From: varjolintu Date: Fri, 2 Apr 2021 17:59:45 +0300 Subject: [PATCH 2/2] Fix variable name --- keepassxc-browser/content/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keepassxc-browser/content/autocomplete.js b/keepassxc-browser/content/autocomplete.js index 6152315..b120520 100644 --- a/keepassxc-browser/content/autocomplete.js +++ b/keepassxc-browser/content/autocomplete.js @@ -203,7 +203,7 @@ class Autocomplete { return; } - this.index = this.elements.findIndex(c => c.value === input.value); + this.index = this.elements.findIndex(c => c.value === inputField.value); if (this.index >= 0) { this.fillPassword(inputField.value, this.index, this.elements[this.index].uuid); }