From bfb309963a96f11ceb01960d8a37bd5bf75aa5ba Mon Sep 17 00:00:00 2001 From: varjolintu Date: Thu, 17 Mar 2022 10:49:49 +0200 Subject: [PATCH] Fix filling TOTP to fields not in combinations --- keepassxc-browser/content/totp-autocomplete.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/keepassxc-browser/content/totp-autocomplete.js b/keepassxc-browser/content/totp-autocomplete.js index 1445d60..b1088e1 100644 --- a/keepassxc-browser/content/totp-autocomplete.js +++ b/keepassxc-browser/content/totp-autocomplete.js @@ -16,7 +16,7 @@ TOTPAutocomplete.prototype.itemClick = async function(e, input, uuid) { } const index = Array.prototype.indexOf.call(e.currentTarget.parentElement.childNodes, e.currentTarget); - this.fillTotp(index, uuid); + await this.fillTotp(index, uuid, input); this.closeList(); input.focus(); @@ -26,11 +26,14 @@ TOTPAutocomplete.prototype.itemEnter = async function(index, elements) { this.fillTotp(index, elements[index].uuid); }; -TOTPAutocomplete.prototype.fillTotp = async function(index, uuid) { +TOTPAutocomplete.prototype.fillTotp = async function(index, uuid, currentInput) { const combination = await kpxcFields.getCombination(this.input, 'totp') || await kpxcFields.getCombination(this.input, 'totpInputs'); - combination.loginId = index; - kpxcFill.fillTOTPFromUuid(this.input, uuid); + if (combination) { + combination.loginId = index; + } + + kpxcFill.fillTOTPFromUuid(this.input || currentInput, uuid); }; const kpxcTOTPAutocomplete = new TOTPAutocomplete();