Uh oh!
There was an error while loading. Please reload this page.
⏳ feat: add opt-in delayError option for setValue - #13337
Conversation
c2b9aa4 to
5fa275bCompareThere 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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…ption-for-setValue-and-trigger
…rm#12992-add-delayError-option-for-setValue-and-trigger
candymask0712
commented
Jun 28, 2026
@bluebill1049 |
bluebill1049
commented
Jun 28, 2026
yea, no worries. we will get this feature out in the following weeks 🙏 thanks for the patient. |
candymask0712
commented
Jun 29, 2026
@bluebill1049 I got it. Thanks for comment! |
…ption-for-setValue-and-trigger
Uh oh!
There was an error while loading. Please reload this page.
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.