ngx-sub-form icon indicating copy to clipboard operation
ngx-sub-form copied to clipboard

Not passing an input to a root form can trigger unexpected behavior in some cases

Open maxime1992 opened this issue 5 years ago • 2 comments

In both

v5:

https://github.com/cloudnc/ngx-sub-form/blob/b8890b887dd1a49b6caee7e3be7be61ebca74aa7/projects/ngx-sub-form/src/lib/ngx-root-form.component.ts#L46

And v6: https://github.com/cloudnc/ngx-sub-form/blob/274420a982b6b7aaa3b7ae449521b4f9f1eeb8f9/projects/ngx-sub-form/src/lib/ngx-sub-form.ts#L151-L167

We do a check on the equality between the previous value of the form and the current one.

If we do not bind the input of a root form (in the case where we care only about the output like a filter) then the old value is never up to date and we can never emit again the default value (which is the case when we clear up the only value changed).

(as an internal reference within our CloudNC repo, @zakhenry check the commit 67be1969d14393ad4d7b4964ca68789f0b539f20 which contains the fix I raised about a month ago for our filter component)

In order to go around this, the input is required and whenever the output of the root form changes, it should come back as the input of it asap. Hence why I'm worried of https://github.com/cloudnc/ngx-sub-form/issues/196

Not sure what we want to do here though, any idea is welcome.

maxime1992 avatar Dec 30 '20 10:12 maxime1992

I kinda feel like that is a bug then - the input should be optional, and if omitted maybe it needs to be rebound to the output

zakhenry avatar Dec 30 '20 14:12 zakhenry

as in (pseudocode)

(
input$: Observable<T> = output$,
) {}

zakhenry avatar Dec 30 '20 14:12 zakhenry