From 0eaa8ee767a742641a33b59ba5e62c1a43c8b357 Mon Sep 17 00:00:00 2001 From: Philip Reimer Date: Tue, 3 Nov 2020 19:34:25 +0100 Subject: [PATCH] fixes #1081 If input field does not have focus: - show autocomplete list if there are multiple credentials - otherwise fill in credentials --- .../content/keepassxc-browser.js | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index ee38c4f..2c336d3 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -727,19 +727,22 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) { } const el = document.activeElement; - if (el.nodeName !== 'INPUT') { - // No active input element selected -> fill the first combination found - if (kpxc.combinations.length > 0) { - kpxc.fillInCredentials(kpxc.combinations[0], kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly); - - // Focus to the input field - const field = passOnly ? kpxc.combinations[0].password : kpxc.combinations[0].username; - if (field) { - field.focus(); - } + if (el.nodeName !== 'INPUT' && kpxc.combinations.length > 0 && kpxc.settings.autoCompleteUsernames) { + // No active input element selected -> focus to the input field + const field = passOnly ? kpxc.combinations[0].password : kpxc.combinations[0].username; + if (field) { + field.focus(); } - return; + 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 && kpxc.combinations.length > 0 && kpxc.settings.autoCompleteUsernames) { kpxcAutocomplete.showList(el); return;