fix(forms/signals): surface debounce window as pending in validateAsync#68367
Open
surajy93 wants to merge 1 commit intoangular:mainfrom
Open
fix(forms/signals): surface debounce window as pending in validateAsync#68367surajy93 wants to merge 1 commit intoangular:mainfrom
surajy93 wants to merge 1 commit intoangular:mainfrom
Conversation
f272b51 to
42447d5
Compare
Previously, the pending state on a form field using validateAsync with debounce option was only set once the debounce duration elapsed and the HTTP call started. During the debounce window the field incorrectly reported pending as false, and stale validation errors from the previous value lingered until the debounce fired. Fix by wrapping the resource returned from the factory with a computed status that returns 'loading' while the debounced params signal is still catching up (debouncedParams.isLoading()), falling back to the inner resource status otherwise. This means: - form.field().pending() === true immediately on the first keystroke - Stale errors from the previous value disappear as soon as the user changes the input, not after the debounce duration Fixes angular#68105 fix(forms): report pending status during debounce window in validateAsync Previously, validateAsync only reported a pending status when the underlying resource loader was active. This caused a UI delay where the field would appear valid (or with old errors) during the debounce window. This change updates validateAsync to check the status of the internal debounced resource and return 'pending' if it is currently in a loading state (waiting for the debounce timer). Added tests to verify pending status during basic debounce and multiple sequential updates.
42447d5 to
dc513b6
Compare
Contributor
Author
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.


Previously, the pending state on a form field using validateAsync with debounce option was only set once the debounce duration elapsed and the HTTP call started. During the debounce window the field incorrectly reported pending as false, and stale validation errors from the previous value lingered until the debounce fired.
Fix by wrapping the resource returned from the factory with a computed status that returns 'loading' while the debounced params signal is still catching up (debouncedParams.isLoading()), falling back to the inner resource status otherwise.
This means:
Fixes #68105
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?
Issue Number: #68105
What is the new behavior?
Does this PR introduce a breaking change?
Other information