1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-07 12:13:45 +00:00

[PM-18721] add type check for ViewChild components

This commit is contained in:
rr-bw
2025-05-24 15:03:52 -07:00
parent cc5c60d374
commit d07fd4663a
2 changed files with 13 additions and 2 deletions

View File

@@ -62,7 +62,7 @@ type EmergencyAccessTakeoverDialogResultType =
})
export class EmergencyAccessTakeoverDialogComponent implements OnInit, AfterViewInit {
@ViewChild(InputPasswordComponent)
inputPasswordComponent!: InputPasswordComponent;
inputPasswordComponent: InputPasswordComponent | undefined = undefined;
private submittingBehaviorSubject = new BehaviorSubject(false);
submitting$ = this.submittingBehaviorSubject.asObservable();
@@ -108,6 +108,10 @@ export class EmergencyAccessTakeoverDialogComponent implements OnInit, AfterView
}
protected handlePrimaryButtonClick = async () => {
if (!this.inputPasswordComponent) {
throw new Error("InputPasswordComponent is not initialized");
}
await this.inputPasswordComponent.submit();
};

View File

@@ -119,7 +119,9 @@ export class InputPasswordComponent implements OnInit {
private submittingBehaviorSubject = new BehaviorSubject(false);
submitting$ = this.submittingBehaviorSubject.asObservable();
@ViewChild(PasswordStrengthV2Component) passwordStrengthComponent!: PasswordStrengthV2Component;
@ViewChild(PasswordStrengthV2Component) passwordStrengthComponent:
| PasswordStrengthV2Component
| undefined = undefined;
@Output() onPasswordFormSubmit = new EventEmitter<PasswordInputResult>();
@Output() onSecondaryButtonClick = new EventEmitter<void>();
@@ -632,6 +634,11 @@ export class InputPasswordComponent implements OnInit {
this.formGroup.patchValue({
newPassword: await this.passwordGenerationService.generatePassword(options),
});
if (!this.passwordStrengthComponent) {
throw new Error("PasswordStrengthComponent is not initialized");
}
this.passwordStrengthComponent.updatePasswordStrength(
this.formGroup.controls.newPassword.value,
);