You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think i discovered a bug caused from the workaround #84
I have a form with few form fields. Some form fields have a subscription on their valueChanges-Event. If this value changes, we reset other fields.
Now the problem is, when the form is disabled by the disabled-attribute (or by this.formGroup.disable({ emitEvent: false });) as default, the valueChanges-Event from above triggers directly on opening the component.
Example:
publicngOnInit(): void{
super.ngOnInit();this.formGroupControls.someField.valueChanges.subscribe(()=>this.resetOtherField());if(this.formModel.isReadonly){this.formGroup.disable();// Passing { emitEvent: false } makes no difference }}
After just opening this form (component) the someField subscription triggers and therefore resets the otherField.
Even with [disabled]="this.formModel.isReadonly" instead of
if(this.formModel.isReadonly){this.formGroup.disable();// Passing { emitEvent: false } makes no difference }
the valueChanges triggers. But the form was not changed at all.
Using v3.0.5 there is no problem, but using > v3.0.6 causes this problem.
I don't find a way to fix this problem by myself, so i created this issue.
Maybe you have tips or a fix for this issue.
Cheers! :-)
The text was updated successfully, but these errors were encountered:
4typen
changed the title
Initial disabled form triggers valueChanges
Initially disabled form triggers valueChanges
May 5, 2020
I have the same problem. I want to disable the form, but all my components inside the form become ng-dirty by default. I'm using ngx-sub-form version 4.0.1
Hi,
I think i discovered a bug caused from the workaround #84
I have a form with few form fields. Some form fields have a subscription on their valueChanges-Event. If this value changes, we reset other fields.
Now the problem is, when the form is disabled by the disabled-attribute (or by
this.formGroup.disable({ emitEvent: false });
) as default, the valueChanges-Event from above triggers directly on opening the component.Example:
After just opening this form (component) the someField subscription triggers and therefore resets the otherField.
Even with
[disabled]="this.formModel.isReadonly"
instead ofthe valueChanges triggers. But the form was not changed at all.
Using v3.0.5 there is no problem, but using > v3.0.6 causes this problem.
I don't find a way to fix this problem by myself, so i created this issue.
Maybe you have tips or a fix for this issue.
Cheers! :-)
The text was updated successfully, but these errors were encountered: