Inconsistent behavior between validators: onSubmit validates error fields on change, whereas onBlur always validates on blur
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- react, typescript
- Área
- frontend
Línea de trabajo
Comienza con la reproducción mínima en el StackBlitz enlazado, en src/index.tsx, y compara los flujos de validación de onBlur y onSubmit descritos en los pasos. Sigue los puntos de entrada relevantes del validador en el paquete de formularios y verifica después que el comportamiento elegido vuelva a validar de forma coherente los campos con errores y que la reproducción ya no requiera un segundo blur.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 6.8k
- Forks
- 705
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 14
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/form
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`Posiblemente ocupada @fenet-as la tomó hace 21 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
TanStack/form#2427 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Async validator doesn't re-trigger `isValidating` after first failed validationPosiblemente ocupada @drewsephski la tomó hace 26 días. Abierto
Dificultad 2/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
[v2 alpha] devtools are always light modePosiblemente ocupada @dikshit-n la tomó hace 60 días. Abiertoarea: runtime scope: devtools type: bug v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
FormGroupApi.getRelatedFields and FieldApi.validate() use unguarded startsWith for group membership, matching unrelated fields with a shared name prefixPosiblemente ocupada @HDPark95 la tomó hace 79 días. Abiertoarea: runtime scope: core type: bug v1
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
TanStack/form#2337 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
FormApi: onSubmit/onServer error cleared on any non-matching validation cause, not just 'change'Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertov1 v2: needs investigation
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/form
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Broken links in the docsAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
🔊 a11y
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
betagouv/mon-entreprise#4726 ·
Los mantenedores suelen responder en 9 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Deltares/fews-pi-requests#357 ·
Los mantenedores suelen responder en 1 día
-
bug confirmed js v6
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día