File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
libs/reactive-forms/src/lib Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -134,5 +134,5 @@ export function controlErrorChanges$(
134
134
export function markAllDirty ( control : AbstractControl ) : void {
135
135
control . markAsDirty ( { onlySelf : true } ) ;
136
136
137
- ( control as any ) . _forEachChild ( ( control : any ) => control . markAllAsDirty ?.( ) ) ;
137
+ ( control as any ) . _forEachChild ( ( control : any ) => control . markAllAsDirty ?.( ) || control . markAsDirty ( { onlySelf : true } ) ) ;
138
138
}
Original file line number Diff line number Diff line change @@ -196,6 +196,20 @@ describe('FormGroup Functionality', () => {
196
196
expect ( spy ) . toHaveBeenCalledWith ( false ) ;
197
197
} ) ;
198
198
199
+ function areAllAllChildrenDirty ( control : AbstractControl ) {
200
+ expect ( control . dirty ) . toBe ( true ) ;
201
+ ( control as any ) . _forEachChild ( ( control : AbstractControl ) => areAllAllChildrenDirty ( control ) ) ;
202
+ }
203
+
204
+ it ( 'should markAllAsDirty' , ( ) => {
205
+ const control = createGroup ( ) ;
206
+
207
+ jest . spyOn ( control , 'markAsDirty' ) ;
208
+ control . markAllAsDirty ( ) ;
209
+ expect ( control . markAsDirty ) . toHaveBeenCalled ( ) ;
210
+ areAllAllChildrenDirty ( control ) ;
211
+ } ) ;
212
+
199
213
it ( 'should reset' , ( ) => {
200
214
const control = createGroup ( ) ;
201
215
jest . spyOn ( control , 'reset' ) ;
You can’t perform that action at this time.
0 commit comments