Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

leonsenft
Copy link
Contributor

@leonsenft leonsenft commented Sep 12, 2025

Move most of the implementation of the Control directive into core framework instructions. This allows field state changes to be propagated to their corresponding UI controls directly during execution of a template update block, instead of relying on effect()s to synchronize each change later during the update (and too late in the case of required inputs).

  • Define a private API in @angular/core for signal forms to implement:
    • ɵControl for the Control directive.
    • ɵFieldState for the control's associated FieldState.
  • Emit specialized instructions when compiling a [control] binding:
    • ɵɵcontrolCreate sets up the ɵControl directive if present, determines whether it's bound to a native control element or a custom control component, and adds the appropriate event listeners to notify the ɵFieldState of UI changes.
    • ɵɵcontrol propagates changes from ɵFieldState properties to their corresponding UI control properties (in additional to binding the control property itself).

Future changes will focus on optimizing the instructions:

  • Cache control-related information on the TNode
  • Limit which properties are updated based on the control type (e.g. only set max/min for number or date)
  • Check if bound values changed before updating their target property or input

* Emit a `ɵɵcontrol` instruction in place of `ɵɵproperty` for property
  bindings named "control". This instruction cannot be chained, but is
  otherwise functionally equivalent.

* Upcoming changes will use the `ɵɵcontrol` instruction to bind a signal
  form field to a UI control (be it a native element or custom directive).
@leonsenft leonsenft added area: core Issues related to the framework runtime area: forms target: major This PR is targeted for the next major release labels Sep 12, 2025
@leonsenft leonsenft added area: compiler Issues related to `ngc`, Angular's template compiler forms: signals labels Sep 12, 2025
@ngbot ngbot bot modified the milestone: Backlog Sep 12, 2025
@leonsenft leonsenft force-pushed the signal-forms-control branch 2 times, most recently from e205267 to 4b76845 Compare September 12, 2025 21:19
@leonsenft leonsenft marked this pull request as draft September 12, 2025 21:30
Move most of the implementation of the `Control` directive into core
framework instructions. This allows field state changes to be propagated
to their corresponding UI controls directly during execution of a
template update block, instead of relying on `effect()`s to synchronize
each change later during the update (and too late in the case of
required inputs).

* Define a private API in `@angular/core` for signal forms to implement:
  * `ɵControl` for the `Control` directive.
  * `ɵFieldState` for the control's associated `FieldState`.
* Emit specialized instructions when compiling a `[control]` binding:
  * `ɵɵcontrolCreate` sets up the `ɵControl` directive if present,
    determines whether it's bound to a native control element or a
    custom control component, and adds the appropriate event listeners
    to notify the `ɵFieldState` of UI changes.
  * `ɵɵcontrol` propagates changes from `ɵFieldState` properties to their
    corresponding UI control properties (in additional to binding the `control`
    property itself).
@leonsenft leonsenft marked this pull request as ready for review September 12, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime area: forms forms: signals target: major This PR is targeted for the next major release
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant