From e0c8ba308a59c5940747446d649918aab9351543 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 23 Mar 2024 13:29:27 +0200 Subject: [PATCH] Fix filling the next field from password generator --- keepassxc-browser/content/pwgen.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/keepassxc-browser/content/pwgen.js b/keepassxc-browser/content/pwgen.js index 9d6f462..62d9321 100644 --- a/keepassxc-browser/content/pwgen.js +++ b/keepassxc-browser/content/pwgen.js @@ -122,8 +122,12 @@ kpxcPasswordGenerator.fill = function(elem, password) { if (elem.getAttribute('maxlength')) { if (password.length > elem.getAttribute('maxlength')) { - const message = tr('passwordGeneratorErrorTooLong') + '\r\n' - + tr('passwordGeneratorErrorTooLongCut') + '\r\n' + tr('passwordGeneratorErrorTooLongRemember'); + const message = + tr('passwordGeneratorErrorTooLong') + + '\r\n' + + tr('passwordGeneratorErrorTooLongCut') + + '\r\n' + + tr('passwordGeneratorErrorTooLongRemember'); message.style.whiteSpace = 'pre'; kpxcUI.createNotification('error', message); return; @@ -137,14 +141,13 @@ kpxcPasswordGenerator.fill = function(elem, password) { // Fill next password field if found if (kpxc.inputs.length > 0) { const index = kpxc.inputs.indexOf(elem); - const nextField = kpxc.inputs[index + 1]; + const next = kpxc.inputs[index + 1]; - kpxcPasswordDialog.nextField = - nextField && nextField.getLowerCaseAttribute('type') === 'password' ? nextField : undefined; - if (kpxcPasswordDialog.nextField) { - kpxcPasswordDialog.nextField.value = password; - kpxcPasswordDialog.nextField.dispatchEvent(new Event('input', { bubbles: true })); - kpxcPasswordDialog.nextField.dispatchEvent(new Event('change', { bubbles: true })); + const nextField = next && next.getLowerCaseAttribute('type') === 'password' ? next : undefined; + if (nextField) { + nextField.value = password; + nextField.dispatchEvent(new Event('input', { bubbles: true })); + nextField.dispatchEvent(new Event('change', { bubbles: true })); } } };