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:
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user