Skip to content

refactor(forms): reorganize control directive & add disabled/readonly #63058

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

Merged

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Aug 8, 2025

Rebase & address comments on #62930, #62933

alxhub and others added 9 commits August 8, 2025 09:53
Split `FormUiControl` into `FormValueControl` and `FormCheckboxControl`,
which capture the two main types of UI control:

 * those that expose a typed `.value()`
 * those that expose a boolean `.checked()`

Implement both in the `Control` directive.
If `[control]` is applied to a custom UI control, it wants to synchronize
state in the field w/ the inputs of that custom control. This is difficult
to do in user-land. We use `effect`, but effects don't run before the
lifecycle hooks of the component. This is usually okay, but has one
significant issue: the UI control's required inputs won't be set in time for
those lifecycle hooks to run.

Eventually we can build custom functionality for the `Control` directive
into the framework, but for now we work around this limitation with a hack.
We use an `@Input` instead of a signal-based `input()` for the `[control]`
to hook the exact moment inputs are being set, before the important
lifecycle hooks of the UI control. We can then initialize all our effects
and force them to run immediately, ensuring all required inputs have values.
When a component is used which represents a subform, it can use a `control`
input to receive and pass down a `Field` to child controls. In that case,
the `Control` directive will match against the component, but should do
nothing since the component is already handling the `Field` propagation
internally.
Switch the test configuration to avoid pulling in zone.js, purely to avoid
the console warning spam.
adds TODOs for open questions on the original PRs, they can be settled in a followup

closes angular#62930
closes angular#62933
@mmalerba mmalerba added area: forms target: feature This PR is targeted for a feature branch (outside of main and semver branches) labels Aug 8, 2025
@ngbot ngbot bot added this to the Backlog milestone Aug 8, 2025
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: docs Related to the documentation labels Aug 8, 2025
@angular-robot angular-robot bot added the area: build & ci Related the build and CI infrastructure of the project label Aug 8, 2025
@mmalerba mmalerba merged commit cb82686 into angular:prototype/signal-forms Aug 8, 2025
15 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build & ci Related the build and CI infrastructure of the project area: docs Related to the documentation area: forms detected: feature PR contains a feature commit target: feature This PR is targeted for a feature branch (outside of main and semver branches)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants