File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ type UseFormRegisterReturn<Value> = {
89
89
name: string
90
90
onBlur: () => void ;
91
91
onChange: () => void ;
92
+ onInput: () => void
92
93
};
93
94
}
94
95
@@ -230,6 +231,7 @@ const { value: bag, attrs: bagFieldAttrs } = register('bag')
230
231
| attrs.name | ` string ` | Input's name that we pass by. |
231
232
| attrs.onBlur | ` (event: Event) => void ` | onBlur prop to subscribe the input blur event. |
232
233
| attrs.onChange | ` () => void ` | onChange prop to subscribe the input change event. |
234
+ | attrs.onInput | ` () => void ` | onInput prop to subscribe the input input event. |
233
235
234
236
** Example**
235
237
@@ -295,6 +297,7 @@ interface FieldEntry {
295
297
attrs: {
296
298
onBlur: (event : Event ) => void ;
297
299
onChange: () => void ;
300
+ onInput: () => void
298
301
};
299
302
}
300
303
```
Original file line number Diff line number Diff line change @@ -286,12 +286,7 @@ export function useForm<Values extends FormValues = FormValues>(
286
286
} ,
287
287
} ) ;
288
288
289
- const willValidate =
290
- shouldValidate == null
291
- ? validateTiming . value === 'input'
292
- : shouldValidate ;
293
-
294
- return willValidate
289
+ return shouldValidate
295
290
? runAllValidateHandler ( state . values )
296
291
: Promise . resolve ( ) ;
297
292
} ;
@@ -372,6 +367,12 @@ export function useForm<Values extends FormValues = FormValues>(
372
367
}
373
368
} ;
374
369
370
+ const handleInput : FormEventHandler [ 'handleInput' ] = ( ) => {
371
+ if ( validateTiming . value === 'input' ) {
372
+ runAllValidateHandler ( state . values ) ;
373
+ }
374
+ } ;
375
+
375
376
const setSubmitting = ( isSubmitting : boolean ) => {
376
377
dispatch ( { type : ACTION_TYPE . SET_ISSUBMITTING , payload : isSubmitting } ) ;
377
378
} ;
@@ -404,6 +405,7 @@ export function useForm<Values extends FormValues = FormValues>(
404
405
name : unref ( name ) ,
405
406
onBlur : handleBlur ,
406
407
onChange : handleChange ,
408
+ onInput : handleInput ,
407
409
} ) ) ;
408
410
} ;
409
411
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export interface FormEventHandler {
48
48
} ;
49
49
50
50
handleChange : ( ) => void ;
51
+ handleInput : ( ) => void ;
51
52
}
52
53
53
54
export interface FieldRegisterOptions < Values > {
@@ -130,6 +131,7 @@ export type FieldAttrs = {
130
131
name : string ;
131
132
onBlur : ( event : Event ) => void ;
132
133
onChange : ( ) => void ;
134
+ onInput : ( ) => void ;
133
135
} ;
134
136
135
137
export type FieldMeta = {
You can’t perform that action at this time.
0 commit comments