File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ type UseFormRegisterReturn<Value> = {
8989 name: string
9090 onBlur: () => void ;
9191 onChange: () => void ;
92+ onInput: () => void
9293 };
9394}
9495
@@ -230,6 +231,7 @@ const { value: bag, attrs: bagFieldAttrs } = register('bag')
230231| attrs.name | ` string ` | Input's name that we pass by. |
231232| attrs.onBlur | ` (event: Event) => void ` | onBlur prop to subscribe the input blur event. |
232233| attrs.onChange | ` () => void ` | onChange prop to subscribe the input change event. |
234+ | attrs.onInput | ` () => void ` | onInput prop to subscribe the input input event. |
233235
234236** Example**
235237
@@ -295,6 +297,7 @@ interface FieldEntry {
295297 attrs: {
296298 onBlur: (event : Event ) => void ;
297299 onChange: () => void ;
300+ onInput: () => void
298301 };
299302}
300303```
Original file line number Diff line number Diff line change @@ -286,12 +286,7 @@ export function useForm<Values extends FormValues = FormValues>(
286286 } ,
287287 } ) ;
288288
289- const willValidate =
290- shouldValidate == null
291- ? validateTiming . value === 'input'
292- : shouldValidate ;
293-
294- return willValidate
289+ return shouldValidate
295290 ? runAllValidateHandler ( state . values )
296291 : Promise . resolve ( ) ;
297292 } ;
@@ -372,6 +367,12 @@ export function useForm<Values extends FormValues = FormValues>(
372367 }
373368 } ;
374369
370+ const handleInput : FormEventHandler [ 'handleInput' ] = ( ) => {
371+ if ( validateTiming . value === 'input' ) {
372+ runAllValidateHandler ( state . values ) ;
373+ }
374+ } ;
375+
375376 const setSubmitting = ( isSubmitting : boolean ) => {
376377 dispatch ( { type : ACTION_TYPE . SET_ISSUBMITTING , payload : isSubmitting } ) ;
377378 } ;
@@ -404,6 +405,7 @@ export function useForm<Values extends FormValues = FormValues>(
404405 name : unref ( name ) ,
405406 onBlur : handleBlur ,
406407 onChange : handleChange ,
408+ onInput : handleInput ,
407409 } ) ) ;
408410 } ;
409411
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export interface FormEventHandler {
4848 } ;
4949
5050 handleChange : ( ) => void ;
51+ handleInput : ( ) => void ;
5152}
5253
5354export interface FieldRegisterOptions < Values > {
@@ -130,6 +131,7 @@ export type FieldAttrs = {
130131 name : string ;
131132 onBlur : ( event : Event ) => void ;
132133 onChange : ( ) => void ;
134+ onInput : ( ) => void ;
133135} ;
134136
135137export type FieldMeta = {
You can’t perform that action at this time.
0 commit comments