Validation onSubmit does not re-trigger with conditionally rendered fields
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
調査の方向性
リンクされた StackBlitz の最小再現から始め、送信シーケンスに従います。1 回送信し、条件付きフィールドを変更してから、もう一度送信します。React フォームのバリデーション経路を追跡し、onSubmit と onChange の動作を比較します。2 回目の送信で新しくレンダリングされたフィールドが一貫してバリデーションされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 6.8k
- フォーク
- 717
- 平均マージ
- 5日 22時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/form のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
Submit listener exceptions leave isSubmitting stuck true対応中かも @henricop が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
handleSubmit calls onSubmit again while a submit is still pending (since 1.33.1)対応中かも @twotnguyen が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`対応中かも @fenet-as が 40 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TanStack/form#2427 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Async validator doesn't re-trigger `isValidating` after first failed validation対応中かも @drewsephski が 44 日前に担当しました。 オープン
難易度 2/5 1〜2日 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
lingdojo/kana-dojo#34449 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
drizzle-team/drizzle-orm#6726 ·
メンテナーはふだん 2 日以内に返信
-
bug platform-desktop platform-windows
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Termix-SSH/Termix#1951 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Grok provider voice list shows 5 of xAI's 28 built-in voices対応中かも @hkjarral が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
hkjarral/AVA-AI-Voice-Agent-for-Asterisk#883 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100