Open maxime1992 opened 4 years ago
Just had a random thought:
If we do this before broadcasting the value up we probably want to check that the form is not disabled
hey @maxime1992
Thank you for the amazing library!
Looking through the formGroup I can see retrieving the disabled value is delegated onto the FormControl.
The FormControl has the API registerOnDisabledChange(fn: (isDisabled: boolean) => void): void
, could we not hook into this to be notified of changes?
It looks to be triggered regardless of the mentioned emitEvent
value defined:
Just another thought on that:
If we turn emitEvent
to true
, with https://github.com/cloudnc/ngx-sub-form/issues/103 we'd broadcast up an empty object which is likely to be an error.
Also, if the RootForm is disabled
we should probably never broadcast any update.
Discussed offline with @zakhenry and Ty:
distinctUntilChanged
To do:
emitEvent: false
:tada: This issue has been resolved in version 5.2.0-feat-rewrite.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
This has now been reverted in the rewrite, unfortunately the rewrite implementation was causing forms to appear to be changed by the user, causing emit side effects. It will need some deeper thought to resolve this properly
:tada: This issue has been resolved in version 5.2.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Context
A classic way of showing that the form is invalid and cannot be saved is by disabling the "send" button.
As we deal with a lot of real time data we're using
NgxAutomaticRootFormComponent
quite a lot and therefore, on these kind of forms, we don't have a save button.To show the user some global feedback on the form we've created a component that takes the formgroup as input and listen to both
statusChanges
andvalueChanges
.Issue
This is not working as if we look into the code of ngx-sub-form:
https://github.com/cloudnc/ngx-sub-form/blob/b8890b887dd1a49b6caee7e3be7be61ebca74aa7/projects/ngx-sub-form/src/lib/ngx-sub-form.component.ts#L417-L421
We're not emitting the disable event.
Why was is done that way?
When calling
disable
orenable
methods, the formGroup emits all the values again. Example:Gives us:
After all, maybe this is expected as it's Angular's behavior anyway but I'm just trying to think if there's any downside updating the code above from
to
Can anyone think of a down side? Or confirm that it's probably a good idea?