File tree Expand file tree Collapse file tree
packages/vue-components/src/components/OmegaForm Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @effect-app/vue-components " : patch
3+ ---
4+
5+ Fixes useOmegaFormErrorStale stale errorMap
Original file line number Diff line number Diff line change @@ -979,6 +979,24 @@ export const useOmegaForm = <
979979 }
980980 } )
981981
982+ // Clear all field onSubmit errors when any value changes after a failed submission.
983+ // Form-level onSubmit validation (e.g. union schemas) distributes errors to individual fields.
984+ // TanStack only clears the changed field's onSubmit error, leaving sibling fields with stale
985+ // errors that keep isFieldsValid=false and block re-submission.
986+ const lastSubmitAttempts = ref ( 0 )
987+ const submissionAttempts = form . useStore ( ( s ) => s . submissionAttempts )
988+ const formValues = form . useStore ( ( s ) => s . values )
989+ watch ( formValues , ( ) => {
990+ if ( lastSubmitAttempts . value === submissionAttempts . value ) return
991+ lastSubmitAttempts . value = submissionAttempts . value
992+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
993+ for ( const info of Object . values ( form . fieldInfo ) as any [ ] ) {
994+ if ( info ?. instance ?. state . meta . errorMap ?. onSubmit ) {
995+ info . instance . setMeta ( ( prev : any ) => ( { ...prev , errorMap : { ...prev . errorMap , onSubmit : undefined } } ) )
996+ }
997+ }
998+ } , { deep : true } )
999+
9821000 const errorContext = { form : formWithExtras , fieldMap }
9831001
9841002 return Object . assign ( formWithExtras , {
You can’t perform that action at this time.
0 commit comments