Skip to content
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: accept deep partials in patchValue and reset methods #54

Merged
merged 1 commit into from
Nov 16, 2020
Merged

fix: accept deep partials in patchValue and reset methods #54

merged 1 commit into from
Nov 16, 2020

Conversation

rafaelss95
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines: CONTRIBUTING.md#commit
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Currently if we try to patchValue a nested form, we got a type error if missing any control in nested structure.

Sample:

this.formGroup = this.formBuilder.group({
  a: this.formBuilder.group({
    b: [1, [Validators.required]],
    c: '2'
  })
});

this.formGroup.patchValue({
  a: { c: '9' } // Error, missing "b"
});

PS: The same applies for formGroup#reset (the reset of FormArray was not using Partial, so I didn't touch it).

Issue Number: N/A

What is the new behavior?

No errors while patchValue for nested structures.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@rafaelss95
Copy link
Contributor Author

Hello @NetanelBasal sry to bump you, but is there any chance of having this reviewed?

@NetanelBasal
Copy link
Member

@itayod, please have a look

@itayod
Copy link
Contributor

itayod commented Nov 16, 2020

@rafaelss95 LGTM, well done!

@itayod
Copy link
Contributor

itayod commented Nov 16, 2020

please resolve the conflicts and then I think we can merge it.

@rafaelss95
Copy link
Contributor Author

Done, @itayod :)

@itayod
Copy link
Contributor

itayod commented Nov 16, 2020

Thanks for the quick response :)

@itayod itayod merged commit ee41c40 into ngneat:master Nov 16, 2020
@rafaelss95 rafaelss95 deleted the fix/deep-partials branch November 16, 2020 14:08
@rafaelss95
Copy link
Contributor Author

@itayod could you publish a version with this? I'm about to use it now 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants