mirror of
https://github.com/angular/angular.git
synced 2026-11-23 07:05:14 -05:00
`markAsTouched()` synchronized a pending debounced value only on the
field it was called on. Its descendants were marked as touched, but
their pending values stayed unsynced.
`submit()` marks the root as touched before running the action, so
submitting with Enter while a debounced child still had focus ran the
action with the child's old value. Clicking a submit button hid the bug,
because the click blurs the input first.
This is a regression from #67453. Before it, `submit()` called the
public `markAsTouched()` on each active field, which flushed it.
Flush each field's pending value right after marking it as touched.
Disabled, hidden and readonly fields still aren't marked as touched, but
unlike before #67453 they are flushed too, so their pending value reaches
the model before the action reads it. Below them only fields that already
exist are visited, since a field that was never created can't have a
pending value.
Tested with new specs in `//packages/forms/signals/test/node:test`. The
specs for descendants, `submit()`, an invalid flushed value, a duration
debounce and sibling fields fail without the fix; another checks that
touching a form doesn't create the fields of a hidden subtree.
Fixes #71149
(cherry picked from commit cf37344a4d)