Inconsistent behavior between validators: onSubmit validates error fields on change, whereas onBlur always validates on blur
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- react, typescript
- Domaine
- frontend
Piste de recherche
Commencez par la reproduction minimale dans le StackBlitz lié, à src/index.tsx, et comparez les flux de validation onBlur et onSubmit décrits dans les étapes. Suivez les points d’entrée pertinents du validateur dans le package de formulaires, puis vérifiez que le comportement choisi revalide systématiquement les champs en erreur et que la reproduction ne nécessite plus un deuxième blur.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
After onBlur validation reveals an error, the onBlur validator will not run again until the field is blurred again. Whereas after onSubmit validation reveals an error, the onSubmit validator will re-run on change. The behavior of all the validators should be consistent. (Although it'd be more convenient for me personally if onBlur re-ran error fields on change but onSubmit re-ran them only on submit 😭)
Imo the correct behavior is to make them both revalidate error fields on change. This falls in line with the research-validated "reward early, punish late" pattern.
Your minimal, reproducible example
https://stackblitz.com/edit/github-vhbc3ekb?file=src%2Findex.tsx
Steps to reproduce
- Blur the first name field without entering any text. You will see an error message for the first name field.
- Enter text into the first name field. You will still see the error message.
- Blur the first name field. The error message will disappear
- Click the submit button. You will see an error message for the last name field.
- Enter text into the last name field. The error message will disappear
Expected behavior
I expected entering the text into the first name field to remove the error message without needing to be blurred first. The error message should disappear on change as soon as the field is valid the same way it works for on submit
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: Mac
- Browser: Chrome v144.0.7559.97
TanStack Form adapter
react-form
TanStack Form version
v1.28.0
TypeScript version
v5.9.3
Additional context
Edit: I thought about it more and the existing onSubmit behavior can be recovered with onDynamic. That's a point in favor of changing onSubmit to work like onBlur instead of the other way around
- Langage dominant
- TypeScript
- Étoiles
- 6.8k
- Forks
- 705
- Merge moyen
- 1 j 12 h
- PR mergées (30 j)
- 14
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TanStack/form
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`Peut-être pris @fenet-as l’a pris il y a 22 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
TanStack/form#2427 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Async validator doesn't re-trigger `isValidating` after first failed validationPeut-être pris @drewsephski l’a pris il y a 26 jours. Ouverte
Difficulté 2/5 1-2 jours Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
[v2 alpha] devtools are always light modePeut-être pris @dikshit-n l’a pris il y a 60 jours. Ouvertearea: runtime scope: devtools type: bug v2
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
FormGroupApi.getRelatedFields and FieldApi.validate() use unguarded startsWith for group membership, matching unrelated fields with a shared name prefixPeut-être pris @HDPark95 l’a pris il y a 79 jours. Ouvertearea: runtime scope: core type: bug v1
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
TanStack/form#2337 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
FormApi: onSubmit/onServer error cleared on any non-matching validation cause, not just 'change'Peut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouvertev1 v2: needs investigation
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de TanStack/form
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
pingdotgg/t3code#30228 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
ci-cd desktop size:low telemetry-improvement telemetry-round-1
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
vfarcic/dot-agent-deck#2079 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
Broken links in the docsOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 83/100
Les mainteneurs répondent en général sous 1 jour