solid-forms icon indicating copy to clipboard operation
solid-forms copied to clipboard

Subscribing to nested FormGroup rawValue props will update whenever sibling props change

Open jorroll opened this issue 3 years ago • 0 comments

If you have a FormGroup with multiple controls, observing control.rawValue.valueA will emit updates even when just control.rawValue.valueB changed.

The reason is that rawValue is changing whenever any nested value changes, so based on the current implementation this is correct behavior. Still, observing changes to rawValue or value is expected to be common enough that we should optimize for it. Perhaps we should store rawValue and value as nested Solidjs Store objects rather than as memos (for both FormGroup and FormArray). This would allow observing deeply nested children and only getting updates when the observed properties change.

At the moment, you could workaround this issue by, e.g., observing control.controls.valueA.rawValue.

jorroll avatar Jul 20 '22 16:07 jorroll