From 589b14a7cc83ba30cae9754d5a2f2751908e8673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20V=C3=A4nttinen?= Date: Sun, 1 Mar 2026 08:32:34 +0200 Subject: [PATCH] Improve retry on input field detection with Custom Login Fields (#2875) --- keepassxc-browser/content/fields.js | 5 +++++ keepassxc-browser/content/keepassxc-browser.js | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/keepassxc-browser/content/fields.js b/keepassxc-browser/content/fields.js index 8465e89..4422a49 100644 --- a/keepassxc-browser/content/fields.js +++ b/keepassxc-browser/content/fields.js @@ -646,6 +646,11 @@ kpxcFields.useCustomLoginFields = async function() { kpxcTOTPIcons.newIcon(totp, kpxc.databaseState); } + // No values found + if (!username && !password && !totp && !submitButton && stringFields?.length === 0) { + return []; + } + const combinations = []; combinations.push({ username: username, diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index b6ac77d..4648625 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -361,7 +361,7 @@ kpxc.initCredentialFields = async function() { // Search all remaining inputs from the page, ignore the previous input fields const pageInputs = await kpxcFields.getAllPageInputs(formInputs); - if (formInputs.length === 0 && pageInputs.length === 0 && !kpxcFields.isCustomLoginFieldsUsed()) { + if (formInputs.length === 0 && pageInputs.length === 0) { // Run 'redetect_credentials' manually if no fields are found after a page load setTimeout(async function() { if (_called.automaticRedetectCompleted) { @@ -653,7 +653,10 @@ kpxc.retrieveCredentials = async function(force = false) { } kpxc.url = document.location.href; - kpxc.submitUrl = kpxc.getFormActionUrl(kpxc.combinations[0]); + + // Search for first combination that has username or password input set + const firstCombination = kpxc.combinations?.find((combination) => combination?.username || combination?.password); + kpxc.submitUrl = kpxc.getFormActionUrl(firstCombination); if (kpxc.settings.autoRetrieveCredentials && kpxc.url && kpxc.submitUrl) { await kpxc.retrieveCredentialsCallback(