feat(forms): Allow a FormControl to use initial value as default.#44434
feat(forms): Allow a FormControl to use initial value as default.#44434dylhunn wants to merge 1 commit intoangular:masterfrom
Conversation
276172d to
2a1062e
Compare
a10c14e to
6f2c319
Compare
|
Presubmit is green: http://test/OCL:415607582:BASE:415607613:1639173976883:195d84c6 |
jessicajaniuk
left a comment
There was a problem hiding this comment.
LGTM 🍪
reviewed-for: public-api
6f2c319 to
a6e6f84
Compare
|
@alxhub I renamed the key to |
a6e6f84 to
0c70f88
Compare
df3a1e7 to
685b8af
Compare
This comment has been minimized.
This comment has been minimized.
packages/forms/src/model.ts
Outdated
There was a problem hiding this comment.
Great catch 👍 I didn't mention this since there is a handling for the "boxed value" in the reset function (within _applyFormState code), but it would also update the disabled status, which is something we need to avoid (so special handling makes sense here).
33335fe to
6940b5e
Compare
6940b5e to
98a9335
Compare
|
(Rebased and all comments addressed) |
98a9335 to
2a1cd13
Compare
|
@alxhub I just did one last push with all the comments addressed! |
|
You can preview 2a1cd13 at https://pr44434-2a1cd13.ngbuilds.io/. |
2a1cd13 to
3ab141c
Compare
|
You can preview 3ab141c at https://pr44434-3ab141c.ngbuilds.io/. |
Allow a FormControl to be reset to its initial value. Provide this feature via a new option in a FormControlOptions interface, based on AbstractControlOptions. Also, expose the default value as part of the public API. This is part of a feature that has been requested elsewhere (e.g. in angular#19747). This was originally proposed as part of typed forms. As discussed in the GDE session (and after with akushnir/alxhub), it is likely better to just reuse the initial value rather than accepting an additional default. It is desirable to land this separately in order to reduce the scope of the typed forms PR, and make it a types-only change. Pertains to issue angular#13721.
3ab141c to
831a87f
Compare
|
You can preview 831a87f at https://pr44434-831a87f.ngbuilds.io/. |
|
This PR was merged into the repository by commit 72092eb. |
|
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. |
Allow a FormControl to be reset to its initial value. Provide this feature via a new option in a FormControlOptions interface, based on AbstractControlOptions.
Also, expose the default value as part of the public API. This is part of a feature that has been requested elsewhere (e.g. in #19747).
This was originally proposed as part of typed forms. As discussed in the GDE session (and after with akushnir/alxhub), it is likely better to just reuse the initial value rather than accepting an additional default.
It is desirable to land this separately in order to reduce the scope of the typed forms PR, and make it a types-only change.
Edit: This change will also help us in a long-term shift to reduce the use of
nullin Forms, and adopt safer defaults.Pertains to issue #13721.
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?
It is impossible to specify the value to which a control will reset ahead of time.
Issue Number: #13721
What is the new behavior?
It is now possible to cause a control to reset to its initial value. This will be useful for simplifying the types in strongly typed reactive forms.
Does this PR introduce a breaking change?
Other information