1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-02 11:31:44 +00:00

[PM-18721] handle cross-component submit states

This commit is contained in:
rr-bw
2025-05-28 01:23:17 -07:00
parent a425fb5ac0
commit e8cbcb0c37
3 changed files with 21 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from "@angular/core";
import { ReactiveFormsModule, FormBuilder, Validators, FormControl } from "@angular/forms";
import { BehaviorSubject, firstValueFrom } from "rxjs";
import { firstValueFrom } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import {
@@ -117,15 +117,13 @@ interface InputPasswordForm {
],
})
export class InputPasswordComponent implements OnInit {
private submittingBehaviorSubject = new BehaviorSubject(false);
submitting$ = this.submittingBehaviorSubject.asObservable();
@ViewChild(PasswordStrengthV2Component) passwordStrengthComponent:
| PasswordStrengthV2Component
| undefined = undefined;
@Output() onPasswordFormSubmit = new EventEmitter<PasswordInputResult>();
@Output() onSecondaryButtonClick = new EventEmitter<void>();
@Output() isSubmitting = new EventEmitter<boolean>();
@Input({ required: true }) flow!: InputPasswordFlow;
@@ -267,7 +265,7 @@ export class InputPasswordComponent implements OnInit {
submit = async () => {
try {
this.submittingBehaviorSubject.next(true);
this.isSubmitting.emit(true);
this.verifyFlow();
@@ -275,7 +273,6 @@ export class InputPasswordComponent implements OnInit {
if (this.formGroup.invalid) {
this.showErrorSummary = true;
this.submittingBehaviorSubject.next(false);
return;
}
@@ -396,7 +393,7 @@ export class InputPasswordComponent implements OnInit {
} catch (e) {
this.validationService.showError(e);
} finally {
this.submittingBehaviorSubject.next(false);
this.isSubmitting.emit(false);
}
};
@@ -453,7 +450,6 @@ export class InputPasswordComponent implements OnInit {
false,
);
if (!newPasswordVerified) {
this.submittingBehaviorSubject.next(false);
return;
}