⏳ feat: add opt-in delayError option for setValue - #13337
Merged
bluebill1049 merged 6 commits intoJul 10, 2026
Merged
bluebill1049 merged 6 commits into
bluebill1049 merged 6 commits into
Conversation
candymask0712
force-pushed
the
fix-#12992-add-delayError-option-for-setValue-and-trigger
branch
from
March 26, 2026 17:08
c2b9aa4 to
5fa275b
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in mechanism for setValue(..., { shouldValidate: true }) to respect the form-level delayError behavior, addressing issue #12992 where validation errors were emitted immediately.
Changes:
- Added
delayErrorboolean toSetValueConfigand propagated it throughsetValue→setFieldValue→trigger. - Implemented delayed error emission logic inside
trigger()when explicitly enabled. - Added test coverage for delayed vs immediate error behavior when using
setValuevalidation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/types/form.ts |
Extends SetValueConfig with a new opt-in flag for delayed error handling. |
src/logic/createFormControl.ts |
Forwards the new option into trigger() and applies delayed error scheduling there. |
src/__tests__/useForm/formState.test.tsx |
Adds regression tests for delayed/immediate/cancelled error display via setValue. |
reports/api-extractor.md.api.md |
Updates API extractor output for the new SetValueConfig field (plus upstream formatting shift). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ption-for-setValue-and-trigger
…rm#12992-add-delayError-option-for-setValue-and-trigger
Contributor
Author
|
@bluebill1049 |
Member
|
yea, no worries. we will get this feature out in the following weeks 🙏 thanks for the patient. |
Contributor
Author
|
@bluebill1049 I got it. Thanks for comment! |
…ption-for-setValue-and-trigger
candymask0712
deleted the
fix-#12992-add-delayError-option-for-setValue-and-trigger
branch
August 1, 2026 10:23
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.
to resolve #12992
Issue
useForm({ delayError: 2000 })is ignored when triggering validation viasetValue('field', value, { shouldValidate: true })— errors are displayed immediately instead of after the configured delay.As @awwwdev reported, there is currently no way to programmatically change an input value and have
delayErrortake effect for showing error messages.Cause
The
setValue→setFieldValue→trigger()path bypassesshouldRenderByError(), which is the only path that applies thedelayErrorlogic.trigger()sets errors directly in_formState.errorsandemits them immediately via
_subjects.state.next().Solution
Added an opt-in
delayError: booleanoption toSetValueConfig. WhensetValueis called with{ shouldValidate: true, delayError: true }, the option is forwarded totrigger(), which removes theerror from
_formState.errorsand re-applies it after the form-leveldelayErrorduration using the existing shareddebounce/timermechanism (consistent withshouldRenderByError).Note:
api-extractor.md.api.mdincludes additional formatting updates from upstream code changes that were not yet reflected in the report.