TanStack / TanStack/form

onSubmit validation skips untouched fields when some fields have onBlur validation

Offen
#1,663 5 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

question v1 v2: needs investigation
Vorherrschende Sprache
TypeScript
Sterne
6.7k
Forks
682
Ø Merge
5 T. 18 Std.
Gemergte PRs (30 T.)
7

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der verknüpften StackBlitz-Reproduktion unter Verwendung des react-form-Adapters und verfolge das Verhalten der Formularübermittlungsvalidierung, wobei für jedes Feld die onBlur-Validierung aktiviert ist. Bestätige, dass das Absenden, nachdem nur First Name den Fokus verloren hat, auch Fehler für das unberührte Last Name und Email meldet, und erhalte dabei das Verhalten, dass beim sofortigen Absenden alle Felder validiert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
react, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.