From 3930189c4e90408eff4a2f60499e842e5011c982 Mon Sep 17 00:00:00 2001 From: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com> Date: Tue, 29 Aug 2023 17:08:02 -0400 Subject: [PATCH] PM-3632 - Vault Timeout Input comp (all clients) - resolve bug where logic which was supposed to initialize the custom vault timeout timeframe if coming from a previously selected numeric timeout was not working properly. (#6102) --- .../components/settings/vault-timeout-input.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/angular/src/components/settings/vault-timeout-input.component.ts b/libs/angular/src/components/settings/vault-timeout-input.component.ts index b0dec5affb..e01a01fdd1 100644 --- a/libs/angular/src/components/settings/vault-timeout-input.component.ts +++ b/libs/angular/src/components/settings/vault-timeout-input.component.ts @@ -76,14 +76,17 @@ export class VaultTimeoutInputComponent } }); - // Assign the previous value to the custom fields + // Assign the current value to the custom fields + // so that if the user goes from a numeric value to custom + // we can initialize the custom fields with the current value + // ex: user picks 5 min, goes to custom, we want to show 0 hr, 5 min in the custom fields this.form.controls.vaultTimeout.valueChanges .pipe( filter((value) => value !== VaultTimeoutInputComponent.CUSTOM_VALUE), takeUntil(this.destroy$) ) - .subscribe((_) => { - const current = Math.max(this.form.value.vaultTimeout, 0); + .subscribe((value) => { + const current = Math.max(value, 0); this.form.patchValue({ custom: { hours: Math.floor(current / 60),