Skip to content

fix: don't set parent error when trigger target has only nested errors - #13730

Merged
bluebill1049 merged 2 commits into
react-hook-form:masterfrom
soroush5:fix/trigger-nested-container-error
Sep 10, 2026
Merged

bluebill1049 merged 2 commits into
react-hook-form:masterfrom
soroush5:fix/trigger-nested-container-error

Conversation

@soroush5

Copy link
Copy Markdown
Contributor

When a resolver returns errors only below a field (e.g. { test: { nested: {...} } }), calling trigger('test') sets the whole container object as errors.test, even though it has no type/message. Same class of bug as #13727, but in the executeSchemaAndUpdateState path that trigger() uses.

The fix only sets the error when it has a type/message (or is an array, for field-array value errors) and unsets otherwise, mirroring #13727.

Repro: new test in trigger.test.tsx — resolver returns only a nested error for test, trigger('test') is clicked, errors.test must stay undefined. Fails before, passes after. Full suite 1347/1347 green, tsc and eslint clean.

@bluebill1049
bluebill1049 merged commit cdcbfca into react-hook-form:master Sep 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants