diff --git a/keepassxc-browser/content/form.js b/keepassxc-browser/content/form.js index 86a156e..d916be0 100644 --- a/keepassxc-browser/content/form.js +++ b/keepassxc-browser/content/form.js @@ -116,9 +116,9 @@ kpxcForm.getNewPassword = function(passwordInputs = []) { } // Choose the last three password fields. The first ones are almost always for something else - const current = passwordInputs[passwordInputs.length - 3].value; - const newPass = passwordInputs[passwordInputs.length - 2].value; - const repeatNew = passwordInputs[passwordInputs.length - 1].value; + const current = passwordInputs[passwordInputs.length - 3]?.value; + const newPass = passwordInputs[passwordInputs.length - 2]?.value; + const repeatNew = passwordInputs[passwordInputs.length - 1]?.value; if ((newPass === repeatNew && current !== newPass && current !== repeatNew) || (current === newPass && repeatNew !== newPass && repeatNew !== current)) { diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index 2351990..2c94c70 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -736,12 +736,20 @@ kpxc.setValue = function(field, value, forced = false) { field.checked = true; } + // Make sure the input is not wrapped inside another element (custom INPUT element) + if (field?.nodeName !== 'INPUT' && field?.nodeName?.includes('INPUT')) { + const childInput = field?.querySelector('input'); + const fieldsFromShadowDOM = kpxcObserverHelper.findInputsFromShadowDOM(field); + field = childInput ?? fieldsFromShadowDOM[0]; + } + + kpxc.setValueWithChange(field, value, forced); }; // Sets a new value to input field and triggers necessary events kpxc.setValueWithChange = function(field, value, forced = false) { - if (!forced && field.readOnly) { + if (!field || (field?.readOnly && !forced)) { return; }