Skip to content

Commit

Permalink
fix: only set fields to isBlurred after field blur or form submit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascalmh committed Sep 5, 2024
1 parent 64fefaa commit 3460639
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions packages/form-core/src/FormApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export class FormApi<
}

// If any fields are not blurred
if (!field.instance.state.meta.isBlurred) {
if (!field.instance.state.meta.isBlurred && cause === 'submit') {
// Mark them as blurred
field.instance.setMeta((prev) => ({ ...prev, isBlurred: true }))
}
Expand Down Expand Up @@ -629,12 +629,6 @@ export class FormApi<
fieldInstance.setMeta((prev) => ({ ...prev, isTouched: true }))
}

// If the field is not blurred (same logic as in validateAllFields)
if (!fieldInstance.state.meta.isBlurred) {
// Mark it as blurred
fieldInstance.setMeta((prev) => ({ ...prev, isBlurred: true }))
}

return fieldInstance.validate(cause)
}

Expand Down

0 comments on commit 3460639

Please sign in to comment.