Repository navigation
Closed as duplicate
Closed as duplicate
Copy link
Milestone
Description
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
The dirty() method on signal form controls always returns false even when field values have been changed from their initial state.
According to standard form behavior, dirty should be true when the current value changes from the initial value.
userModel = signal<IUserModel>({
name: '',
email: '',
password: '',
confirmPassword: ''
})
userForm = form(this.userModel, (field) => {
required(field.name, {message: 'Name is required'});
required(field.email, {message: 'Email is required'});
email(field.email, {message: 'Email is not valid'});
required(field.password, {message: 'Password is required'});
required(field.confirmPassword, {message: 'Confirm Password is required'});
})
onSubmit(event: Event) {
event.preventDefault();
console.log('Form Value ==>', this.userForm().value());
console.log('Form valid ==>', this.userForm().valid());
console.log('Form touched ==>', this.userForm().touched());
console.log('Form dirty ==>', this.userForm().dirty());
}
<form (submit)="onSubmit($event)"
class="flex flex-col gap-4 p-4 border border-gray-300 rounded-lg max-w-md mx-auto mt-20">
<label for="name" class="flex flex-col gap-1">
Name
<input id="name" [field]="userForm.name" type="text" class="border border-indigo-500 p-2"
placeholder="please enter your name"/>
</label>
<label for="email" class="flex flex-col gap-1">
Email
@if (userForm.email().errors().length) {
@for (error of userForm.email().errors(); track error.message) {
<span class="text-red-500 text-sm">{{ error.message }}</span>
}
}
<input id="email" [field]="userForm.email" type="email" class="border border-indigo-500 p-2"
placeholder="please enter your email"/>
</label>
<label for="password" class="flex flex-col gap-1">
Enter Password
<input id="password" [field]="userForm.password" type="password" class="border border-indigo-500 p-2"
placeholder="please enter your password"/>
</label>
<label for="confirm-password" class="flex flex-col gap-1">
Confirm Password
<input id="confirm-password" [field]="userForm.confirmPassword" type="password" class="border border-indigo-500 p-2"
placeholder="please enter your confirm password"/>
</label>
<button type="submit" class=" cursor-pointer bg-indigo-500 text-white p-2 rounded hover:bg-indigo-600 transition"
>
Submit
</button>
</form>
I have also revised this with @SanderElias
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
Angular CLI : 21.0.0-next.8
Angular : 21.0.0-next.8
Node.js : 22.14.0
Package Manager : npm 10.9.2
Operating System : win32 x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.0.0-next.8 │ ^21.0.0-next.7 │
│ @angular/cli │ 21.0.0-next.8 │ ^21.0.0-next.7 │
│ @angular/common │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/compiler │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/compiler-cli │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/core │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/forms │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/platform-browser │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/router │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.2
Anything else?
No response
Activity
JeanMeche commentedon Oct 16, 2025
Yup, it looks like dirtiness isn't really implemented yet.
Touched works fine because all field are marked as touched on submit.
angular/packages/forms/signals/src/api/structure.ts
Lines 394 to 399 in a7ba2f5
But
markAsDirty()is never invoked anywhre.angular/packages/forms/signals/src/field/node.ts
Lines 192 to 194 in a7ba2f5
kirjs commentedon Oct 16, 2025
Thanks, looks like this might be a regression, we're looking into this.
aparzi commentedon Oct 16, 2025
@JeanMeche @kirjs
Can this issue be linked to this one? #63623
fix(forms): mark field as dirty when value is changed by a bound control
leonsenft commentedon Oct 16, 2025
This was indeed a regression. This should be fixed in #64483.
leonsenft commentedon Oct 16, 2025
@JeanMeche Technically not a duplicate as one was an issue for native controls while the other was for custom controls, but they're both being fixed in the same PR 🤷♂️ (this was a regression while the other was never implemented).
fix(forms): mark field as dirty when value is changed by a bound cont…
angular-automatic-lock-bot commentedon Nov 16, 2025
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.