Repository navigation
Description
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
When a child field uses debounce(), submitting the form can pass the action the child's old value instead of what the user typed.
submit() calls markAsTouched() on the form root. markAsTouched() flushes the pending debounced value only for the field it is called on. Descendants are marked as touched, but their pending values are not flushed.
This shows up when the user presses Enter inside a debounced input. The input keeps focus, so the value is still pending when the action runs. Clicking a submit button hides the bug, because the click blurs the input and flushes its value first.
readonly profileForm = form(
this.model,
(p) => {
debounce(p.name, 'blur');
},
{
submission: {
action: async (f) => {
console.log(f.name().value()); // "" after typing "Ada" and pressing Enter
},
},
},
);<form [formRoot]="profileForm">
<input [formField]="profileForm.name" />
<button type="submit">Submit</button>
</form>Steps:
- Type "Ada" in the input.
- Press Enter while the input still has focus.
Expected: the action receives "Ada".
Actual: the action receives "", and the model still holds "".
A duration debounce such as debounce(p.name, 500) has the same problem if Enter is pressed before the duration elapses.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-b1x3y5vd?file=package.json
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
Angular CLI : 22.2.1
Angular : 22.2.1
Node.js : 22.22.3
Package Manager : npm 10.8.2
Operating System : linux x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 22.2.1 │ ^22.2.0 │
│ @angular/cli │ 22.2.1 │ ^22.2.0 │
│ @angular/common │ 22.2.1 │ 22.2.1 │
│ @angular/compiler │ 22.2.1 │ 22.2.1 │
│ @angular/compiler-cli │ 22.2.1 │ 22.2.1 │
│ @angular/core │ 22.2.1 │ 22.2.1 │
│ @angular/forms │ 22.2.1 │ 22.2.1 │
│ @angular/platform-browser │ 22.2.1 │ 22.2.1 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 6.0.3 │ ~6.0.0 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else?
No response
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(forms): flush debounced descendant values when a field is touched
fix(forms): flush debounced descendant values when a field is touched
fix(forms): flush debounced descendant values when a field is touched
fix(forms): flush debounced descendant values when a field is touched
fix(forms): flush debounced descendant values when a field is touched
fix(forms): flush debounced descendant values when a field is touched
fix(forms): flush debounced descendant values when a field is touched