feat(forms): allow markAsPending to emit events (#20212)
closes #17958 BREAKING CHANGE: - `AbstractControl#statusChanges` now emits an event of `'PENDING'` when you call `AbstractControl#markAsPending` - Previously it did not emit an event when you called `markAsPending` - To migrate you would need to ensure that if you are filtering or checking events from `statusChanges` that you account for the new event when calling `markAsPending` PR Close #20212
This commit is contained in:
committed by
Victor Berchet
parent
90e9c59e23
commit
e86b64b620
@@ -357,10 +357,18 @@ export abstract class AbstractControl {
|
||||
|
||||
/**
|
||||
* Marks the control as `pending`.
|
||||
*
|
||||
* An event will be emitted by `statusChanges` by default.
|
||||
*
|
||||
* Passing `false` for `emitEvent` will cause `statusChanges` to not event an event.
|
||||
*/
|
||||
markAsPending(opts: {onlySelf?: boolean} = {}): void {
|
||||
markAsPending(opts: {onlySelf?: boolean, emitEvent?: boolean} = {}): void {
|
||||
(this as{status: string}).status = PENDING;
|
||||
|
||||
if (opts.emitEvent !== false) {
|
||||
(this.statusChanges as EventEmitter<any>).emit(this.status);
|
||||
}
|
||||
|
||||
if (this._parent && !opts.onlySelf) {
|
||||
this._parent.markAsPending(opts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user