diff --git a/keepassxc-browser/content/totp-field.js b/keepassxc-browser/content/totp-field.js index b6a2d7c..9d5b9f5 100644 --- a/keepassxc-browser/content/totp-field.js +++ b/keepassxc-browser/content/totp-field.js @@ -108,16 +108,8 @@ class TOTPFieldIcon extends Icon { } } -TOTPFieldIcon.prototype.initField = async function(field, segmented) { - // Observer the visibility - if (this.observer) { - this.observer.observe(field); - } - - this.createIcon(field, segmented); - this.inputField = field; - - // Fill TOTP automatically if option is enabled +// Fill TOTP automatically if option is enabled +TOTPFieldIcon.prototype.autoFillSingleTotp = async function(field) { if (kpxc.settings.autoFillSingleTotp) { if (kpxc.credentials.length === 0) { await kpxc.receiveCredentialsIfNecessary(); @@ -129,6 +121,18 @@ TOTPFieldIcon.prototype.initField = async function(field, segmented) { } }; +TOTPFieldIcon.prototype.initField = async function(field, segmented) { + // Observer the visibility + if (this.observer) { + this.observer.observe(field); + } + + this.createIcon(field, segmented); + this.inputField = field; + + await this.autoFillSingleTotp(field); +}; + TOTPFieldIcon.prototype.createIcon = function(field, segmented = false) { const className = (isFirefox() ? 'moz' : 'default');