Validation onSubmit does not re-trigger with conditionally rendered fields
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- react, typescript
Direzione di ricerca
Inizia con la riproduzione minima collegata di StackBlitz e segui la sequenza di invio: invia una volta, modifica il campo condizionale, quindi invia di nuovo. Traccia il percorso di validazione del form React e confronta il comportamento di onSubmit con quello di onChange; il lavoro è completo quando il secondo invio valida in modo coerente il campo appena renderizzato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
The onSubmit validator is not re-triggering after first time when a "dynamic" field has changed. In this case I'm using Zod's discriminated union to decide whether to show this or that field, but this bug happens also when using for example a superRefine to conditionally validate a field. The first submit triggers correctly the onSubmit validator, but then if we change the field and show the other input field and submit again, it does not work trigger the validator. Even with canSubmitWhenInvalid: true.
There is a similar issue #1780 that points to this error but it's not actually the same. In that issue the author resolved the issue just putting canSubmitWhenInvalid: true, but actually the problem we have found is in the validation not getting triggered.
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-form-q2pndiqf?file=src%2Findex.tsx
Steps to reproduce
- Click on Submit -> Should show the error for
thisField - Change the Select to the value That
- Click again on Submit -> Should show the error for
thatField, but it does not.
If we change the validators to run on onChange, it works!
It works also if after submitting you change an input or on blur.
Expected behavior
I would expect that the onSubmit validator would run on submitting the form and it would have the same result of the onChange schema validation
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: MacOS
- Browser: Chrome
- Version: 142.0.7444.60
TanStack Form adapter
react-form
TanStack Form version
1.25.0
TypeScript version
5.9.3
Additional context
No response
- Lingua principale
- TypeScript
- Stelle
- 6.8k
- Fork
- 717
- Merge medio
- 5g 22h
- 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
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Submit listener exceptions leave isSubmitting stuck trueForse già presa @henricop l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
handleSubmit calls onSubmit again while a submit is still pending (since 1.33.1)Forse già presa @twotnguyen l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`Forse già presa @fenet-as l’ha presa 40 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 44 giorni fa. Aperta
Difficoltà 2/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/form
Issue simili
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
lingdojo/kana-dojo#34449 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
drizzle-team/drizzle-orm#6726 ·
I maintainer di solito rispondono entro 2 giorni
-
bug platform-desktop platform-windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
Termix-SSH/Termix#1951 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Grok provider voice list shows 5 of xAI's 28 built-in voicesForse già presa @hkjarral l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
hkjarral/AVA-AI-Voice-Agent-for-Asterisk#883 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100