-
Notifications
You must be signed in to change notification settings - Fork 26.9k
feat(@angular/forms): add ng-submitted class #31070
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
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
I signed it! |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
Note to the team: this is a first time contributor, contributing to Angular during the HackCommitPush conference, which aims to help developers to contribute to open source projects :) CI failure looks like an unrelated flake |
jasonaden
left a comment
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.
Overall this looks good. Just a couple notes. Thanks for the submission!
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.
Initially looking at this I was confused because you're checking for this._controlContainer to exist when the constructor here say's required. But in NgControlStatus below you've marked it as @Optional. However, as far as TypeScript goes it's still required.
I would like to make the types align correctly. You will need to use @Inject along with making the ControlContainer optional in order for the JIT compiler to behave. Something like this:
export class AbstractControlStatus {
...
constructor(cd: AbstractControlDirective, controlContainer?: ControlContainer) { ... }
}
and
export class NgControlStatus extends AbstractControlStatus {
constructor(@Self() cd: NgControl, @Inject(ControlContainer) @Optional() controlContainer?: ControlContainer) { ... }
}
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.
Make sure to update the public API docs as well to mark this optional.
|
@edwandr can you clean up. |
edwandr
left a comment
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.
@jasonaden Thanks for the feedbacks !
@mhevery I'll clean up in the week
08fe213 to
67728a7
Compare
edwandr
left a comment
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.
@jasonaden i added the optional type for controlContainer argument
67728a7 to
0200127
Compare
0200127 to
40ff640
Compare
40ff640 to
f538908
Compare
Add ng-submitted class to form controls when parent form has been submitted Fixes angular#30486
f538908 to
3c7aca1
Compare
|
@mhevery @jasonaden Hi, happy new year ! Are the modifications i pushed ok for you ? |
|
(just for additional context: related issue #30486) |
AndrewKushnir
left a comment
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.
Hi @edwandr, thanks for submitting this PR and sorry that we didn't have a chance to get back to it sooner.
I've reviewed the changes and I think that we should simplify the changes and support the ng-submitted class only for the classes that actually have this status, i.e. NgForm and FormGroupDirective (the directives that can represent the top-level form). Other form elements (like <input>s) would be able to use the top-level form's status to set specific styling if needed (for ex.: .ng-submitted input { font-size: 10px; }).
Please let us know if you might be interested in making additional changes in this PR.
Thank you.
|
Closing this PR, new PR - #42132. |
|
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. |
Add ng-submitted class to form controls when parent form has been submitted
Fixes #30486
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
No class is added to form controls and container when parent form is submitted
Issue Number: 30486
What is the new behavior?
When parent form is submitted (if there is a parent form), form controls get
ng-submittedclassDoes this PR introduce a breaking change?
Constructor arguments of
NgControlStatushave changed : we added one optional injected argumentcontrolContainerOther information
Would it be better to add
submittedproperty toForminterface (whichNgFormandFormGroupDirectiveimplement) ?This would avoid the imports of these to directives in
ng_control_status.ts. I'm afraid that importing them could increase bundle size.