Skip to content

Commit

Permalink
fix: do not use angular internal function markDirty as it may not b…
Browse files Browse the repository at this point in the history
…een useful yet and causes issues
  • Loading branch information
maxime1992 committed Nov 21, 2021
1 parent 20b5dea commit 908e4b7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions projects/ngx-sub-form/new/src/ngx-sub-form.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ɵmarkDirty as markDirty } from '@angular/core';
// import { ɵmarkDirty as markDirty } from '@angular/core';
import isEqual from 'fast-deep-equal';
import { decorateObservableLifecycle, getObservableLifecycle } from 'ngx-observable-lifecycle';
import { EMPTY, forkJoin, Observable, of } from 'rxjs';
Expand Down Expand Up @@ -169,12 +169,12 @@ export function createForm<ControlInterface, FormInterface>(
);
} else {
return formGroup.valueChanges.pipe(
delay(0),
delay(0),
filter(formValue => formGroup.valid && !isEqual(transformedValue, formValue)),
);
}
}
}),
}
}),
map(value =>
isRemap<ControlInterface, FormInterface>(options)
? options.fromFormGroup(value)
Expand Down Expand Up @@ -205,9 +205,15 @@ export function createForm<ControlInterface, FormInterface>(

formGroup.reset(value);

// commenting out the following for now as it seems that calling
// `markDirty` on a component when an input hasn't been set
// (in this case on a root form) then it throws an error
// Cannot read property 'nodeIndex' of null
// so we'll see later on if this is really needed or if it can
// be removed
// support `changeDetection: ChangeDetectionStrategy.OnPush`
// on the component hosting a form
markDirty(componentInstance);
// markDirty(componentInstance);
}),
),
setDisabledState$: setDisabledState$.pipe(
Expand Down

0 comments on commit 908e4b7

Please sign in to comment.