1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

[PM-2135] feat: hack mark as touched to get error to display

This commit is contained in:
Andreas Coroiu
2023-05-05 14:40:10 +02:00
parent f69b42a622
commit 8ebaff3612
2 changed files with 11 additions and 2 deletions

View File

@@ -27,6 +27,9 @@ export class UserVerificationComponent implements ControlValueAccessor, OnInit {
set invalidSecret(value: boolean) { set invalidSecret(value: boolean) {
this._invalidSecret = value; this._invalidSecret = value;
this.invalidSecretChange.emit(value); this.invalidSecretChange.emit(value);
if (value) {
this.secret.markAsTouched();
}
this.secret.updateValueAndValidity({ emitEvent: false }); this.secret.updateValueAndValidity({ emitEvent: false });
} }
@Output() invalidSecretChange = new EventEmitter<boolean>(); @Output() invalidSecretChange = new EventEmitter<boolean>();

View File

@@ -78,9 +78,15 @@ export class BitInputDirective implements BitFormFieldControl {
return this.id; return this.id;
} }
private isActive = true;
@HostListener("blur")
onBlur() {
this.isActive = true;
}
@HostListener("input") @HostListener("input")
onInput() { onInput() {
this.ngControl?.control?.markAsUntouched(); this.isActive = false;
} }
get hasError() { get hasError() {
@@ -91,7 +97,7 @@ export class BitInputDirective implements BitFormFieldControl {
this.ngControl?.errors != null this.ngControl?.errors != null
); );
} else { } else {
return this.ngControl?.status === "INVALID" && this.ngControl?.touched; return this.ngControl?.status === "INVALID" && this.ngControl?.touched && this.isActive;
} }
} }