Inconsistent behavior between validators: onSubmit validates error fields on change, whereas onBlur always validates on blur
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- react, typescript
- Ambito
- frontend
Direzione di ricerca
Inizia con la riproduzione minima nello StackBlitz collegato, in src/index.tsx, e confronta i flussi di convalida onBlur e onSubmit descritti nei passaggi. Traccia i punti di ingresso rilevanti del validatore nel pacchetto dei form, quindi verifica che il comportamento scelto convalidi nuovamente in modo coerente i campi con errori e che la riproduzione non richieda più un secondo blur.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 6.8k
- Fork
- 705
- Merge medio
- 1g 12h
- PR unite (30g)
- 14
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/form
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`Forse già presa @fenet-as l’ha presa 21 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
TanStack/form#2427 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Async validator doesn't re-trigger `isValidating` after first failed validationForse già presa @drewsephski l’ha presa 25 giorni fa. Aperta
Difficoltà 2/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[v2 alpha] devtools are always light modeForse già presa @dikshit-n l’ha presa 59 giorni fa. Apertaarea: runtime scope: devtools type: bug v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
FormGroupApi.getRelatedFields and FieldApi.validate() use unguarded startsWith for group membership, matching unrelated fields with a shared name prefixForse già presa @HDPark95 l’ha presa 78 giorni fa. Apertaarea: runtime scope: core type: bug v1
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
TanStack/form#2337 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
FormApi: onSubmit/onServer error cleared on any non-matching validation cause, not just 'change'Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertav1 v2: needs investigation
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/form
Issue simili
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
microsoft/playwright#43875 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
calagopus/panel#285 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 88/100
adobe/react-spectrum#10909 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Run the dependency drift checkForse già presa @spaceninja l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
cloudfour/lighthouse-parade#449 ·
I maintainer di solito rispondono entro 1 giorno