TanStack / TanStack/form

onSubmit validation skips untouched fields when some fields have onBlur validation

Aperta
#1,663 5 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

question v1 v2: needs investigation
Lingua principale
TypeScript
Stelle
6.7k
Fork
682
Merge medio
5g 18h
PR unite (30g)
7

Descrizione

Describe the bug

When using TanStack Form with onBlur validation on all individual fields and onSubmit for the entire form, the onSubmit validation only validates fields that have been "touched" (focused/blurred). Fields that haven't been interacted with are skipped during form submission validation, even though they should be validated.

Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-sviy39k3?file=src%2FApp.tsx

Steps to reproduce
  1. Focus and blur the "First Name" field (leave it empty)
  2. Leave the "Last Name" and "Email" fields completely untouched
  3. Click "Submit Form"
  4. Notice that only First Name shows an error, but Last Name and Email don't

Note: If you submit without blurring any fields, all fields are correctly validated and show errors.

Expected behavior

All fields should be validated on form submission, regardless of whether they have been touched or not. The onSubmit validation should validate the entire form schema, not just the "dirty" fields.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform
  • OS: macOS 15.5
  • Browser: Chrome
  • Version: 138.0.7204.184
TanStack Form adapter

react-form

TanStack Form version

v1.15.2

TypeScript version

v5.9.2

Additional context

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione StackBlitz collegata usando l’adattatore react-form e segui il comportamento della validazione all’invio del modulo con la validazione onBlur abilitata su ogni campo. Verifica che l’invio dopo che solo First Name ha perso il focus segnali errori anche per Last Name e Email, che non sono stati toccati, preservando al contempo il comportamento per cui l’invio immediato convalida tutti i campi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
react, typescript
Ambito
frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.