X Tutup
Skip to content

fix: resetField({ value: undefined }) form validity#5136

Open
logaretm wants to merge 1 commit intomainfrom
fix/4996-resetfield-undefined-valid
Open

fix: resetField({ value: undefined }) form validity#5136
logaretm wants to merge 1 commit intomainfrom
fix/4996-resetfield-undefined-valid

Conversation

@logaretm
Copy link
Owner

@logaretm logaretm commented Mar 4, 2026

Summary

Root Cause

The resetField function in useForm.ts was missing two things that resetForm (and useField's resetField) already did:

  1. Reset pathState.validated = false -- Without this, the field's validated flag stayed true from prior validation/submission, leaving the field in an inconsistent state after reset.
  2. Run a silent validation in nextTick -- Without this, the pathState.valid flag was not recalculated against the schema after the field value was reset, which could leave the form's meta.valid in an incorrect state.

Test plan

  • Added test: resetField with undefined value should not prevent form from becoming valid
  • Verified the test fails without the fix (pathState.validated remains true after reset)
  • Verified the test passes with the fix
  • All existing 356 tests pass (3 pre-existing infrastructure failures unrelated to this change)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 4, 2026 06:39
@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: d75959f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for vee-validate-v5 ready!

Name Link
🔨 Latest commit d75959f
🔍 Latest deploy log https://app.netlify.com/projects/vee-validate-v5/deploys/69a7d3945491c200086a1479
😎 Deploy Preview https://deploy-preview-5136--vee-validate-v5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for vee-validate-docs canceled.

Name Link
🔨 Latest commit d75959f
🔍 Latest deploy log https://app.netlify.com/projects/vee-validate-docs/deploys/69a7d394ed353200081f5ce9

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a regression where calling resetField({ value: undefined }) could leave meta.valid stuck in an invalid state even after the user enters a new valid value, by aligning useForm.resetField() behavior with resetForm() / useField.resetField().

Changes:

  • Reset pathState.validated to false inside useForm.resetField().
  • Trigger a nextTick silent validation (validateField(..., { mode: 'silent' })) after resetting a field to recompute pathState.valid against the schema.
  • Add a regression test covering resetField with an undefined value and subsequent valid input.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/vee-validate/src/useForm.ts Resets validated and runs post-reset silent validation to keep field/form validity in sync with schema.
packages/vee-validate/tests/useForm.spec.ts Adds regression coverage for issue #4996.
.changeset/fix-4996-resetfield-undefined.md Adds a patch changeset entry documenting the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

resetField({ value: undefined }) prevents the form from becoming valid after updating the field

2 participants

X Tutup