-
Notifications
You must be signed in to change notification settings - Fork 25.4k
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 ourterms of serviceand privacy statement.We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(forms): AddFormArrayDirective
#55880
base: main
Are you sure you want to change the base?
Conversation
35741f0
to
2d950c1
Compare
2d950c1
to
f29120d
Compare
f29120d
to
25997b4
Compare
25997b4
to
d6271bb
Compare
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.
@JeanMecheI had a quick look and the changes look good. I want to ask if you could split the commit into 2:
- first
refactor
commit performs a refactoring and extracts out the common logic into the abstract form directive class - the second
feat
commit that adds a new directive
That should help to make the change more incremental and help with more detailed code review.
7a959ab
to
e7d47d9
Compare
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.
Thanks for splitting up the change in this way! Let's merge thisafterthe RC, so we can get it on the 18.2 track, and we'll have plenty of time to receive feedback from GDEs and other early users.
e7d47d9
to
211260e
Compare
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.
The change looks good, thanks for splitting the change into 2 commits 👍
I've left a few comments, but a bigger question that I have is about potential collisions with existing[formArray]
usages in templates:
- as a custom directive
- as an input to a component
I've checked internal codebase and there are ~75 instances of the[formArray]
in templates. Adding a new directive to theReactiveFormsModule
will cause conflicts with those locations.
I think we'd need to do some research to find a way to avoid those conflicts or do some cleanup internally. cc@dylhunnto get your opinion on this as well.
packages/forms/src/directives/reactive_directives/form_group_name.ts
Outdated
Show resolved
Hide resolved
@@ -5812,6 +5825,132 @@ describe('reactive forms integration tests', () => { | |||
fixture.destroy(); | |||
}).not.toThrow(); | |||
}); | |||
|
|||
describe('formArray support', () => { |
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.
I'm curious if we may want to add a check that[formArray]
and[formGroup]
should not be present on the same element? Can we have valid use-cases where it might be needed (e.g. they bind to different data structures)?
packages/forms/src/directives/reactive_directives/form_array_directive.ts
Outdated
Show resolved
Hide resolved
packages/forms/src/directives/reactive_directives/form_group_directive.ts
Outdated
Show resolved
Hide resolved
211260e
to
2173e87
Compare
I'm moving this to major / breaking change as it was discovered that there were already usages of a formArray directive (or formArray as input) inside Google. |
Ahead of the implementation of `FormArrayDirective`, extract the shared logic into an abstract class.
The `FormArrayDirective` will allow to have a `FormArray` as a top-level form object. * `NgControlStatusGroup` directive will be applied to the `FormArrayDirective` * `NgForm` will still create a `FormGroup` Fixesangular#30264 BREAKING CHANGE: This new directive will conflict with existing FormArray directives or formArray inputs on the same element.
2173e87
to
949e2e0
Compare
This commit exposes a new type to the public api. It is intented to also include the upcomming `FormArrayDirective` (angular#55880)
This commit exposes a new type to the public api. It is intented to also include the upcomming `FormArrayDirective` (angular#55880)
The
FormArrayDirective
will allow to have aFormArray
as a top-level form object.NgControlStatusGroup
directive will be applied to theFormArrayDirective
NgForm
will still create aFormGroup
Usage:
Fixes#30264
BREAKING CHANGE: This new directive will conflict with existing FormArray directives or formArray inputs on the same element.