fix(forms): prevent stale CVA writeback during debounce#69436
Open
BHUVANSH855 wants to merge 2 commits into
Open
fix(forms): prevent stale CVA writeback during debounce#69436BHUVANSH855 wants to merge 2 commits into
BHUVANSH855 wants to merge 2 commits into
Conversation
Use controlValue() instead of value() when synchronizing ControlValueAccessor instances. When debounce is active, value() can still contain the previous model value while controlValue() reflects the latest user-entered value. This prevents stale values from being written back to the CVA before the debounce is flushed. Adds a regression test covering the debounce scenario.
bd22f2f to
49c0547
Compare
Register the custom writeback test control as an NG_VALUE_ACCESSOR so it is recognized as a valid formField host during debounce writeback testing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When a Signal Forms field uses
debounce(),ControlValueAccessorsynchronization reads fromfieldState.value(). During the debounce period, this value can still contain the previous model value even though the control has already received a newer user-entered value.As a result, the stale model value may be written back to the CVA before the debounced update is flushed.
Issue Number: #69387
What is the new behavior?
ControlValueAccessorsynchronization now usesfieldState.controlValue()instead offieldState.value().This ensures that CVAs receive the latest control value while a debounce is pending, preventing stale values from being written back to the control.
A regression test has been added to verify that no stale write-back occurs when debounce is active.
Does this PR introduce a breaking change?
Other information
The change aligns CVA synchronization behavior with the existing implementations in
control_custom.tsandcontrol_native.ts, which already usecontrolValue().