Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions projects/ngx-sub-form/src/lib/ngx-sub-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ export abstract class NgxSubFormComponent<ControlInterface, FormInterface = Cont
// calling `reset` on a form with `null` throws an error but if nothing is passed
// (undefined) it will reset all the form values to null (as expected)
defaultValues === null ? undefined : defaultValues,
{ emitEvent: false },
// emit to keep internal and external information about data in of control in sync, when
// null/undefined was passed into writeValue
// while internally being replaced with defaultValues
{ emitEvent: isNullOrUndefined(obj) && !isNullOrUndefined(defaultValues) },
);
} else {
const missingKeys: (keyof FormInterface)[] = this.getMissingKeys(transformedValue);
Expand All @@ -269,7 +272,10 @@ export abstract class NgxSubFormComponent<ControlInterface, FormInterface = Cont
const fgDisabled: boolean = this.formGroup.disabled;

this.formGroup.setValue(transformedValue, {
emitEvent: false,
// emit to keep internal and external information about data in of control in sync, when
// null/undefined was passed into writeValue
// while internally being replaced with transformedValue
emitEvent: isNullOrUndefined(obj),
});

if (fgDisabled) {
Expand Down