Skip to content

signal-forms: FormValueControl is unable to mark field as dirty #63623

Closed

Description

@ThiloAschebrock

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

No

Description

I have been playing around with the new FormValueControl interface to implement custom controls in signal forms.

I noticed that FormValueControl does not automatically mark the field as dirty if the value changes and lacks the ability to manually mark as dirty because dirty is only exposed as an input signal to FormValueControl.

@Component({
  selector: 'app-input',
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <input 
      [value]="value()"
      (input)="setValue($event)"
      (blur)="markTouched()"
    />
  `,
})
export class Input implements FormValueControl<string> {
  readonly value = model<string>('');
  readonly touched = model<boolean>(false);
  readonly dirty = input<boolean>(false);

  setValue(event: Event) {
    this.value.set((event.target as HTMLInputElement).value);
  }

  markTouched() {
    this.touched.set(true);
  }
}

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-tyvqgwbf?file=src%2Fmain.ts

Please provide the exception or error you saw

When implementing a custom input via `FormValueControl` the field will not automatically be marked as dirty and cannot be marked as dirty via the provided interface.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 21.0.0-next.2
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64
    

Angular: 21.0.0-next.2
... build, cli, common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                      Version
------------------------------------
@angular-devkit/architect    0.2100.0-next.2
@angular-devkit/core         21.0.0-next.2
@angular-devkit/schematics   21.0.0-next.2
@schematics/angular          21.0.0-next.2
rxjs                         7.8.2
typescript                   5.9.2

Anything else?

The signal form prototype already looks amazing!

Activity

  1. ThiloAschebrock commented on Sep 6, 2025

    @ThiloAschebrock
    Author

    It looks to me like a similar issue might also be present for the integration of Control with ControlValueAccessor, cf. https://github.com/angular/angular/blob/main/packages/forms/signals/src/controls/control.ts#L323.

  2. modified the milestone: needsTriage on Sep 6, 2025
  3. leonsenft commented on Oct 16, 2025

    @leonsenft
    Contributor

    Thanks for the report, this should be fixed in #64483.

  4. angular-automatic-lock-bot commented on Nov 17, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions