Field-level `onMount` errors are never cleared on linked-field revalidation
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
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- react, typescript
- Ambito
- frontend
Direzione di ricerca
Inizia con il flusso di rivalidazione dei campi collegati nella riproduzione StackBlitz, concentrandoti su onMount, onChangeListenTo, errorMap e sulla validità dello stato del campo. Verifica che la modifica di password rivalidi correttamente confirmPassword; il lavoro è completato quando l’errore obsoleto di onMount viene cancellato e sia field.isValid sia form.isValid diventano true senza toccare confirmPassword.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
When a field has a field-level onMount validator and is linked to another field, the onMount error is never cleared, even when the other validators on that field run successfully via the linked-field mechanism and report the field as valid.
The result is that field.state.meta.errors keeps surfacing the stale mount-time error and isValid stays false indefinitely or until you touch the field. This also propagates to form.state.isValid, breaking submit-button enablement and any UI that depends on per-field validity.
Possibly related to #689, #903
Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-ywiic5qt?file=src%2FApp.tsx
Steps to reproduce
- Open the StackBlitz repro.
- Observe the initial state: password is empty, confirmPassword defaults to "password". The confirmPassword field's onMount validator correctly reports "Passwords do not match" in
errorMap.onMount, and isValid is false. This is expected. - Type "password" into the Password input. Do not touch the Confirm Password input.
- The onChange validator on confirmPassword runs via
onChangeListenTo: ["password"]and correctly returns undefined —errorMap.onChangeis now undefined. - Bug:
errorMap.onMountstill shows"Passwords do not match", and bothconfirmPassword.isValidandform.isValidremain false, even though both validators on the field, given the current values, return undefined.
Expected behavior
As a user, I expected the onMount error to clear once the field's other validators run successfully via the linked-field mechanism, but I am seeing the onMount error persist indefinitely (or until it's touched), leaving the field marked as invalid even though all of its validators agree that it is valid.
How often does this bug happen?
Every time
Platform
- OS: macOS
- Browser: Google Chrome
- Version: 146.0.7680.178
TanStack Form adapter
react-form
TanStack Form version
v.1.29.0
TypeScript version
v6.0.2
Additional context
Not sure whether to classify this as a bug or a design choice. onMount only clearing on direct value changes could be a deliberate "the user must acknowledge this field" rule. But it does feel like an edge case worth revisiting, given that onChangeListenTo / onBlurListenTo exist specifically for cross-field patterns.
If the current behavior is intentional, an opt-in to let successful linked-field revalidation clear the stale onMount slot would be very helpful. The only workaround I've found is to manually clear the slot via setMeta from a listener on the source field, which is fragile and easy to forget.
- Lingua principale
- TypeScript
- Stelle
- 6.7k
- Fork
- 689
- Merge medio
- 2g 11h
- PR unite (30g)
- 13
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à 2/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
area: 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
-
area: 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'Apertav1 v2: needs investigation
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
v1 v2: needs investigation
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
TanStack/form#2294 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/form
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
betagouv/mon-entreprise#4699 ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
jaegertracing/jaeger-ui#4547 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
ai-driven-qa
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
linagora/twake-calendar-frontend#1467 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
need4deed-org/sdk#267 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
auth0/universal-login#414 ·
I maintainer di solito rispondono entro 1 giorno