From 9b7f57cc757c8b92c4a73ea8a0d99218f6e7a33e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 3 Jan 2022 22:25:28 +0100 Subject: [PATCH] web/flows: add workaround for autofocus not working in password stage Signed-off-by: Jens Langhammer --- .../flows/stages/password/PasswordStage.ts | 47 +++++++++++++++---- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/web/src/flows/stages/password/PasswordStage.ts b/web/src/flows/stages/password/PasswordStage.ts index e57dd6ecf..2eec3c27b 100644 --- a/web/src/flows/stages/password/PasswordStage.ts +++ b/web/src/flows/stages/password/PasswordStage.ts @@ -26,6 +26,42 @@ export class PasswordStage extends BaseStage { + if (!this.input) { + return; + } + if (document.activeElement === this.input) { + this.cleanup(); + } + this.input.focus(); + }, 10); + console.debug("authentik/stages/password: started focus timer"); + return this.input; + } + + cleanup(): void { + if (this.timer) { + console.debug("authentik/stages/password: cleared focus timer"); + window.clearInterval(this.timer); + } + } + render(): TemplateResult { if (!this.challenge) { return html` `; @@ -63,16 +99,7 @@ export class PasswordStage extends BaseStage - + ${this.renderInput()} ${this.challenge.recoveryUrl