Skip to content

fix(forms): ensure reset cancels pending debounce and syncs controlValue#68353

Open
surajy93 wants to merge 1 commit intoangular:mainfrom
surajy93:fix/signal-forms-reset-debounce
Open

fix(forms): ensure reset cancels pending debounce and syncs controlValue#68353
surajy93 wants to merge 1 commit intoangular:mainfrom
surajy93:fix/signal-forms-reset-debounce

Conversation

@surajy93
Copy link
Copy Markdown
Contributor

@surajy93 surajy93 commented Apr 23, 2026

Abort any pending debounce before resetting to prevent stale sync() from overwriting the reset value.

Force controlValue to match value during reset, even when the value has not changed, ensuring the UI does not retain stale user input.

markAsDirty() triggered by controlValue.set() is neutralized by markAsPristine(), and no unnecessary sync is triggered since values are already aligned.

Fixes: #68076

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #68076

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove pullapprove Bot requested a review from crisbeto April 23, 2026 16:39
@amishne amishne added the target: patch This PR is targeted for the next patch release label Apr 23, 2026
@ngbot ngbot Bot added this to the Backlog milestone Apr 23, 2026
@JeanMeche JeanMeche requested review from kirjs and leonsenft and removed request for crisbeto April 23, 2026 20:09
Comment thread packages/forms/signals/src/field/node.ts
@surajy93 surajy93 force-pushed the fix/signal-forms-reset-debounce branch from c8d3f5d to dd94f36 Compare April 25, 2026 07:23
@surajy93 surajy93 requested a review from leonsenft April 25, 2026 07:24
});
});

describe('FieldNode._reset() unit tests', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first two tests above are perfect–they test user visible behavior. 👍

While I appreciate the thoroughness, these remaining tests are only testing internal implementation details which we explicitly do not want to do. For example, it's possible we refactor the internals such that the observable behavior is unchanged, but now these tests fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks for the feedback! Removed the FieldNode._reset() unit tests block.
The two behavioral tests covering the debounce scenarios (promise-based and blur-based) are still in place.

Abort any pending debounce before resetting to prevent stale sync() from overwriting the reset value.

Force controlValue to match value during reset, even when the value has not changed, ensuring the UI does not retain stale user input.

markAsDirty() triggered by controlValue.set() is neutralized by markAsPristine(), and no unnecessary sync is triggered since values are already aligned.
@surajy93 surajy93 force-pushed the fix/signal-forms-reset-debounce branch from dd94f36 to ef3b6ca Compare April 28, 2026 02:44
@surajy93 surajy93 requested a review from leonsenft April 28, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: forms target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signal forms reset broken while editing and form has debounce()

3 participants