-
Notifications
You must be signed in to change notification settings - Fork 26.2k
feat(forms): add default updateOn values to groups and arrays #18536
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
2194b86
to
b5323b2
Compare
You can preview 0ba8999 at https://pr18536-0ba8999.ngbuilds.io/. |
You can preview 2194b86 at https://pr18536-2194b86.ngbuilds.io/. |
You can preview b5323b2 at https://pr18536-b5323b2.ngbuilds.io/. |
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.
LGTM
dispatchEvent(input, 'input'); | ||
fixture.detectChanges(); | ||
|
||
expect(control.value).toEqual('', 'Expected value to remain unchanged until submit.'); |
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.
nit: Also check the value is unchanged when blurred?
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.
Oh, good point. 👌
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.
Should be updated now!
You can preview 7231271 at https://pr18536-7231271.ngbuilds.io/. |
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.
please add short property-level api doc snippet
packages/forms/src/model.ts
Outdated
@@ -242,6 +245,10 @@ export abstract class AbstractControl { | |||
*/ | |||
get statusChanges(): Observable<any> { return this._statusChanges; } | |||
|
|||
get updateOn(): FormHooks { |
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.
Please add api docs
This commit adds support for setting default `updateOn` values in `FormGroups` and `FormArrays`. If you set `updateOn` to ’blur’` at the group level, all child controls will default to `’blur’`, unless the child has explicitly specified a different `updateOn` value. ``` const c = new FormGroup({ one: new FormControl() }, {updateOn: blur}); ``` It's worth noting that parent groups will always update their value and validity immediately upon value/validity updates from children. In other words, if a group is set to update on blur and its children are individually set to update on change, the group will still update on change with its children; its default value will simply not be used.
You can preview e4695c2 at https://pr18536-e4695c2.ngbuilds.io/. |
You can preview c838fe3 at https://pr18536-c838fe3.ngbuilds.io/. |
…ar#18536) This commit adds support for setting default `updateOn` values in `FormGroups` and `FormArrays`. If you set `updateOn` to ’blur’` at the group level, all child controls will default to `’blur’`, unless the child has explicitly specified a different `updateOn` value. ``` const c = new FormGroup({ one: new FormControl() }, {updateOn: blur}); ``` It's worth noting that parent groups will always update their value and validity immediately upon value/validity updates from children. In other words, if a group is set to update on blur and its children are individually set to update on change, the group will still update on change with its children; its default value will simply not be used.
…ar#18536) This commit adds support for setting default `updateOn` values in `FormGroups` and `FormArrays`. If you set `updateOn` to ’blur’` at the group level, all child controls will default to `’blur’`, unless the child has explicitly specified a different `updateOn` value. ``` const c = new FormGroup({ one: new FormControl() }, {updateOn: blur}); ``` It's worth noting that parent groups will always update their value and validity immediately upon value/validity updates from children. In other words, if a group is set to update on blur and its children are individually set to update on change, the group will still update on change with its children; its default value will simply not be used.
…ar#18536) This commit adds support for setting default `updateOn` values in `FormGroups` and `FormArrays`. If you set `updateOn` to ’blur’` at the group level, all child controls will default to `’blur’`, unless the child has explicitly specified a different `updateOn` value. ``` const c = new FormGroup({ one: new FormControl() }, {updateOn: blur}); ``` It's worth noting that parent groups will always update their value and validity immediately upon value/validity updates from children. In other words, if a group is set to update on blur and its children are individually set to update on change, the group will still update on change with its children; its default value will simply not be used.
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 PR adds support for setting default
updateOn
values inFormGroups
andFormArrays
. If you setupdateOn
to'blur'
at the group level, all child controls will default to'blur'
, unless the child has explicitly specified a differentupdateOn
value.It's worth noting that parent groups will always update their value and validity immediately upon value/validity updates from children. In other words, if a group is set to update on
blur
and its children are individually set to update onchange
, the group will still update on change with its children; its default value will simply not be used.Upcoming PRs will address:
See more context in #18408, #18514, and the design doc.