Inconsistent behavior between validators: onSubmit validates error fields on change, whereas onBlur always validates on blur
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
リンクされた StackBlitz の src/index.tsx にある最小再現から始め、手順で説明されている onBlur と onSubmit のバリデーションフローを比較します。form パッケージ内の関連する validator のエントリポイントを追跡し、選択した動作によってエラーのあるフィールドが一貫して再バリデーションされ、再現で 2 回目の blur が不要になっていることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 6.8k
- フォーク
- 705
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/form のほかの issue
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`対応中かも @fenet-as が 22 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TanStack/form#2427 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Async validator doesn't re-trigger `isValidating` after first failed validation対応中かも @drewsephski が 27 日前に担当しました。 オープン
難易度 2/5 1〜2日 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[v2 alpha] devtools are always light mode対応中かも @dikshit-n が 61 日前に担当しました。 オープンarea: runtime scope: devtools type: bug v2
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
FormGroupApi.getRelatedFields and FieldApi.validate() use unguarded startsWith for group membership, matching unrelated fields with a shared name prefix対応中かも @HDPark95 が 80 日前に担当しました。 オープンarea: runtime scope: core type: bug v1
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
TanStack/form#2337 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
FormApi: onSubmit/onServer error cleared on any non-matching validation cause, not just 'change'再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンv1 v2: needs investigation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
test: claim-conflict drop leaves both facts active and is never re-proposed (untested review cell)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
[Feature]: Usage page should show API-equivalent cost and say when a connected plan shows info onlyオープンenhancement from-x
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
nightly-labs/openbot#4867 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
egonSchiele/agency-lang#1377 ·
メンテナーはふだん 1 日以内に返信
-
normalizePath removes the Windows device namespace prefix対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
caprover/caprover-frontend#273 ·
メンテナーはふだん 1 日以内に返信