@@ -4,6 +4,7 @@ import { FieldGroupApi, functionalUpdate } from '@tanstack/form-core'
4
4
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
5
5
import type {
6
6
AnyFieldGroupApi ,
7
+ DeepKeys ,
7
8
DeepKeysOfType ,
8
9
FieldGroupState ,
9
10
FieldsMap ,
@@ -194,11 +195,46 @@ export function useFieldGroup<
194
195
return < form . AppForm { ...appFormProps } />
195
196
}
196
197
198
+ const remapProps = ( fieldProps : Record < string , any > ) => {
199
+ const newProps = { ...fieldProps }
200
+ const validators = newProps . validators
201
+
202
+ if (
203
+ validators &&
204
+ ( validators . onChangeListenTo || validators . onBlurListenTo )
205
+ ) {
206
+ const newValidators = { ...validators }
207
+
208
+ const remapListenTo = ( listenTo : DeepKeys < any > [ ] | undefined ) => {
209
+ if ( ! listenTo ) return undefined
210
+ return listenTo . map ( ( localFieldName ) =>
211
+ formLensApi . getFormFieldName ( localFieldName ) ,
212
+ )
213
+ }
214
+
215
+ if ( newValidators . onChangeListenTo ) {
216
+ newValidators . onChangeListenTo = remapListenTo (
217
+ newValidators . onChangeListenTo ,
218
+ )
219
+ }
220
+
221
+ if ( newValidators . onBlurListenTo ) {
222
+ newValidators . onBlurListenTo = remapListenTo (
223
+ newValidators . onBlurListenTo ,
224
+ )
225
+ }
226
+
227
+ newProps . validators = newValidators
228
+ }
229
+
230
+ return newProps
231
+ }
232
+
197
233
extendedApi . AppField = function AppField ( { name, ...appFieldProps } ) {
198
234
return (
199
235
< form . AppField
200
236
name = { formLensApi . getFormFieldName ( name ) }
201
- { ...( appFieldProps as any ) }
237
+ { ...( remapProps ( appFieldProps ) as any ) }
202
238
/>
203
239
) as never
204
240
}
@@ -207,7 +243,7 @@ export function useFieldGroup<
207
243
return (
208
244
< form . Field
209
245
name = { formLensApi . getFormFieldName ( name ) }
210
- { ...( fieldProps as any ) }
246
+ { ...( remapProps ( fieldProps ) as any ) }
211
247
/>
212
248
) as never
213
249
}
0 commit comments