fix(forms): changes to status not always being emitted to statusChanges observable for async validators. (#42553)
When a FormControl, FormArray, or FormGroup is first constructed, if an async validator is attached, the `statusChanges` observable should receive a message when the validator complete (i.e. pending -> valid/invalid). If the validator was provided as part of the constructor options, it was not fired at construction time, which is fixed in this PR. Fixes #35309. PR Close #42553
This commit is contained in:
committed by
Alex Rickabaugh
parent
56a0582d79
commit
7180ec9e7c
@@ -1167,7 +1167,7 @@ export class FormControl extends AbstractControl {
|
||||
// `VALID` or `INVALID`.
|
||||
// The status should be broadcasted via the `statusChanges` observable, so we set `emitEvent`
|
||||
// to `true` to allow that during the control creation process.
|
||||
emitEvent: !!asyncValidator
|
||||
emitEvent: !!this.asyncValidator
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1433,7 +1433,7 @@ export class FormGroup extends AbstractControl {
|
||||
// If `asyncValidator` is present, it will trigger control status change from `PENDING` to
|
||||
// `VALID` or `INVALID`. The status should be broadcasted via the `statusChanges` observable,
|
||||
// so we set `emitEvent` to `true` to allow that during the control creation process.
|
||||
emitEvent: !!asyncValidator
|
||||
emitEvent: !!this.asyncValidator
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1887,7 +1887,7 @@ export class FormArray extends AbstractControl {
|
||||
// `VALID` or `INVALID`.
|
||||
// The status should be broadcasted via the `statusChanges` observable, so we set `emitEvent`
|
||||
// to `true` to allow that during the control creation process.
|
||||
emitEvent: !!asyncValidator
|
||||
emitEvent: !!this.asyncValidator
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user