Inconsistent behavior between validators: onSubmit validates error fields on change, whereas onBlur always validates on blur
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- react, typescript
- Bereich
- frontend
Rechercherichtung
Beginne mit der minimalen Reproduktion im verknüpften StackBlitz unter src/index.tsx und vergleiche die in den Schritten beschriebenen Validierungsabläufe von onBlur und onSubmit. Verfolge die relevanten Validator-Einstiegspunkte im Formularpaket und überprüfe anschließend, dass das gewählte Verhalten fehlerhafte Felder konsistent erneut validiert und die Reproduktion keinen zweiten Blur mehr erfordert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.8k
- Forks
- 705
- Ø Merge
- 1 T. 12 Std.
- Gemergte PRs (30 T.)
- 14
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/form
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`Evtl. vergeben @fenet-as hat das vor 21 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
TanStack/form#2427 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Async validator doesn't re-trigger `isValidating` after first failed validationEvtl. vergeben @drewsephski hat das vor 25 Tagen übernommen. Offen
Schwierigkeit 2/5 1-2 Tage Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
[v2 alpha] devtools are always light modeEvtl. vergeben @dikshit-n hat das vor 59 Tagen übernommen. Offenarea: runtime scope: devtools type: bug v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
FormGroupApi.getRelatedFields and FieldApi.validate() use unguarded startsWith for group membership, matching unrelated fields with a shared name prefixEvtl. vergeben @HDPark95 hat das vor 78 Tagen übernommen. Offenarea: runtime scope: core type: bug v1
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
TanStack/form#2337 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
FormApi: onSubmit/onServer error cleared on any non-matching validation cause, not just 'change'Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offenv1 v2: needs investigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Remove unused dependenciesEvtl. vergeben @alastair-smith hat das heute übernommen. Offenchore other
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
alastair-smith/card-games#384 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
code-yeongyu/senpi#5571 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nexu-io/open-design#9262 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
friction
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
kentcdodds/kody#4753 ·
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
lingdojo/kana-dojo#33508 · 1 Kommentar · 5 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag