-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(forms): allow patchValue
method of FormGroup
and FormArray
classes to skip null
values
#40534
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fairly simple fix - LGTM.
I think there is a typo in the commit message:
...iterate over provided value...
->
...iterate over provided values...
Also (NITs):
- I prefer to add
()
when mentioning functions in commit messages (e.g.patchValue()
rather thanpatchValue
) since it helps when scanning the text. - The bit in brackets
(for FormControl it's not a problem, since it doesn't have nested controls)
could be moved to its own sentence after the end of this sentence, since it kind of gets in the way of the main description of the commit.
…` classes to skip `null` values Prior to this commit, the `patchValue()` of the `FormGroup` and `FormArray` classes used to throw an exception when the `value` argument contained a data structure that has `null` or `undefined` as a value for a field that represents an instance of `FormGroup` or `FormArray` (for `FormControl` it's not a problem, since it doesn't have nested controls), since the `patchValue()` method tried to iterate over provided values to match current data structure. This commit updates the `patchValue()` logic in `FormGroup` and `FormArray` classes to just ignore `null` and `undefined` values (without any changes to corresponding `FormGroup` and `FormArray` instances). This behavior looks inline with the `patchValue()` method goal of "doing its best to match the values to the correct controls" (quote from docs). Fixes angular#36672. Fixes angular#21021.
d10e3f1
to
ac7985b
Compare
…` classes to skip `null` values (#40534) Prior to this commit, the `patchValue()` of the `FormGroup` and `FormArray` classes used to throw an exception when the `value` argument contained a data structure that has `null` or `undefined` as a value for a field that represents an instance of `FormGroup` or `FormArray` (for `FormControl` it's not a problem, since it doesn't have nested controls), since the `patchValue()` method tried to iterate over provided values to match current data structure. This commit updates the `patchValue()` logic in `FormGroup` and `FormArray` classes to just ignore `null` and `undefined` values (without any changes to corresponding `FormGroup` and `FormArray` instances). This behavior looks inline with the `patchValue()` method goal of "doing its best to match the values to the correct controls" (quote from docs). Fixes #36672. Fixes #21021. PR Close #40534
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Prior to this commit, the
patchValue
of theFormGroup
andFormArray
classes used to throw an exceptionwhen the
value
argument contained a data structure that hasnull
orundefined
as a value for a fieldthat represents an instance of
FormGroup
orFormArray
(forFormControl
it's not a problem, since itdoesn't have nested controls), since the
patchValue
method tried to iterate over provided value tomatch current data structure.
This commit updates the
patchValue
logic inFormGroup
andFormArray
classes to just ignorenull
andundefined
values (without any changes to correspondingFormGroup
andFormArray
instances). Thisbehavior is inline with the
patchValue
method goal of "doing its best to match the values to the correct controls"(quote from docs).
Fixes #36672.
Fixes #21021.
PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?