-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
feat(forms): add emitEvent
option for AbstractControl-based class methods
#31031
feat(forms): add emitEvent
option for AbstractControl-based class methods
#31031
Conversation
I don't know why the build is failing, it was working in PR #29664 which had exactly the same code changes |
Do we have some news about PR review? |
Hi @MikeJerred, sorry we didn't have a chance to review/reply earlier. As I mentioned in #20439 (comment), we'd like to consider adding Thank you. |
b0ea8b2
to
07cce2a
Compare
@AndrewKushnir I have rebased this PR and added the changes to |
Hi @MikeJerred, thanks for updating the PR! The CI failure was a flake, restarting that CI job resolved the issue. I will review the changes within the next couple days and get back with comments/feedback. Thank you. |
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.
@MikeJerred thanks for updating the PR! The changes look good, I've just left a few comments related to docs and tests. Please let me know if you have any questions and/or need any help. Thank you.
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 additional changes @MikeJerred 👍
I've left a few more comments mostly around docs to rephrase them a bit to be aligned with the function itself.
Just as a thought for a future refactoring (later in a separate PR), it'd be great to make description of the opts
argument more generic (do not name the action specifically, but just refer to it as the "current action"), so that it's easier to maintain. The docs may look like:
* @param opts Allows to specify whether events should be emitted once the current
* operation is completed.
* * `emitEvent`: When true or not supplied (the default), both `statusChanges` and
* `valueChanges` events are emitted with the latest status and value. When false, no
* events are emitted.
We'd probably need to revisit exiting functions as well and update opts
argument docs in a similar way. But this is definitely outside of the scope of this PR (I'll create a ticket once this PR lands).
Thank you.
@MikeJerred thanks for applying the changes. I noticed that you've changed the implementation for Also I want to share the next steps:
Thank you. |
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.
Great. Thanks @MikeJerred
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.
Reviewed-for: public-api
Presubmit #2 + Global Presubmit #2 (internal-only links). |
You can preview 21dad98 at https://pr31031-21dad98.ngbuilds.io/. |
@MikeJerred quick update: tests in Google's codebase went well (after minor updates to classes that extend FormGroup and FormArray). We are very close to merging this change and the last step would be to squash all commits into one and add the "BREAKING CHANGE" note to the commit body, so the commit message may look like this:
Please let us know once it's ready, we'll do final checks and add this PR to the merge queue. Thank you. |
473821f
to
fa419d8
Compare
@AndrewKushnir I have squashed the commits into one and adjusted the message. |
@MikeJerred there are some typos in your commit: |
…ethods This commit adds the `emitEvent` option to the following FormArray and FormGroup methods: * FormGroup.addControl * FormGroup.removeControl * FormGroup.setControl * FormArray.push * FormArray.insert * FormArray.removeAt * FormArray.setControl * FormArray.clear This option can be used to prevent an event from being emitted when adding or removing controls. BREAKING CHANGE: The `emitEvent` option was added to the following `FormArray` and `FormGroup` methods: * FormGroup.addControl * FormGroup.removeControl * FormGroup.setControl * FormArray.push * FormArray.insert * FormArray.removeAt * FormArray.setControl * FormArray.clear If your app has custom classes that extend `FormArray` or `FormGroup` classes and override the above-mentioned methods, you may need to update your implementation to take the new options into account and make sure that overrides are compatible from a types perspective. Closes angular#29662.
fa419d8
to
960c354
Compare
FYI, started a new presubmit in Google's codebase (internal-only link) to verify that there there are no places that might be broken by this change. Will keep this thread updated. |
FYI all affected tests in Google's codebase are successful, so I'm adding this PR to the merge queue. @MikeJerred thanks for working on this PR and addressing the feedback! The change will be merged into the master branch and should be available as a part of the next major release (v12) in a few weeks. |
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. |
This commit adds an optional argument to the methods addControl
and removeControl in the FormGroup class. This argument can be
used to prevent an event from being emitted.
PR Close #29662
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?
Issue Number: #29662
What is the new behavior?
An argument can now be specified to prevent an event from being emitted.
Does this PR introduce a breaking change?
Other information