From c82c5dd0b6e26ce7f0e3f1043793d2b6b1b01dd5 Mon Sep 17 00:00:00 2001 From: Philip Reimer Date: Wed, 11 Nov 2020 00:39:58 +0100 Subject: [PATCH] set focus to username or password input field regardless of the currently active element if at least one combination exists and autocomplete is enabled --- .../content/keepassxc-browser.js | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index 24f5fd1..0cee121 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -726,30 +726,24 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) { return; } - const el = document.activeElement; - if (kpxc.combinations.length > 0 && kpxc.settings.autoCompleteUsernames) { const field = passOnly ? kpxc.combinations[0].password : kpxc.combinations[0].username; - if (field && field.id !== el.id) { - // focus to the correct input field - field.focus(); + // set focus to the input field + field.focus(); - if (kpxc.credentials.length > 1) { - // More than one credential -> show autocomplete list - kpxcAutocomplete.showList(field); - return - } else { - // Just one credential -> fill the first combination found - kpxc.fillInCredentials(kpxc.combinations[0], kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly); - return; - } - } else if (kpxc.credentials.length > 1) { - kpxcAutocomplete.showList(el); + if (kpxc.credentials.length > 1) { + // More than one credential -> show autocomplete list + kpxcAutocomplete.showList(field); + return + } else { + // Just one credential -> fill the first combination found + kpxc.fillInCredentials(kpxc.combinations[0], kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly); return; } } // No previous combinations detected. Create a new one from active element + const el = document.activeElement; let combination; if (kpxc.combinations.length === 0) { combination = await kpxc.createCombination(el);