fix(forms): async validator cancels previous subscription when input has changed (#13222)
Fixes #12709 Fixes #9120 Fixes #10074 Fixes #8923 PR Close #13222
This commit is contained in:
committed by
Miško Hevery
parent
22058298d3
commit
6c7300c7de
@@ -384,6 +384,7 @@ export abstract class AbstractControl {
|
||||
this._updateValue();
|
||||
|
||||
if (this.enabled) {
|
||||
this._cancelExistingSubscription();
|
||||
this._errors = this._runValidator();
|
||||
this._status = this._calculateStatus();
|
||||
|
||||
@@ -417,7 +418,6 @@ export abstract class AbstractControl {
|
||||
private _runAsyncValidator(emitEvent: boolean): void {
|
||||
if (this.asyncValidator) {
|
||||
this._status = PENDING;
|
||||
this._cancelExistingSubscription();
|
||||
const obs = toObservable(this.asyncValidator(this));
|
||||
this._asyncValidationSubscription =
|
||||
obs.subscribe({next: (res: {[key: string]: any}) => this.setErrors(res, {emitEvent})});
|
||||
|
||||
Reference in New Issue
Block a user