File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import type {
1313 FormValuesShape ,
1414 Unsubscribe
1515} from 'final-form'
16- import type { FormProps as Props } from './types'
16+ import type { FormProps as Props , SubmitEvent } from './types'
1717import renderComponent from './renderComponent'
1818import useWhenValueChanges from './useWhenValueChanges'
1919import useConstant from './useConstant'
@@ -163,7 +163,7 @@ function ReactFinalForm<FormValues: FormValuesShape>({
163163 form . setConfig ( 'validateOnBlur' , validateOnBlur )
164164 } )
165165
166- const handleSubmit = (event: ?SyntheticEvent < HTMLFormElement > ) => {
166+ const handleSubmit = (event: ?SubmitEvent ) => {
167167 if ( event ) {
168168 // sometimes not true, e.g. React Native
169169 if ( typeof event . preventDefault === 'function' ) {
Original file line number Diff line number Diff line change @@ -51,8 +51,16 @@ export type FieldRenderProps = {
5151 }
5252}
5353
54+ export type SubmitEvent = {
55+ preventDefault?: $PropertyType<SyntheticEvent<EventTarget>, 'preventDefault'>,
56+ stopPropagation?: $PropertyType<
57+ SyntheticEvent<EventTarget>,
58+ 'stopPropagation'
59+ >
60+ }
61+
5462export type FormRenderProps<FormValues: FormValuesShape> = {
55- handleSubmit: (?SyntheticEvent<HTMLFormElement> ) => ?Promise<?Object>,
63+ handleSubmit: (?SubmitEvent ) => ?Promise<?Object>,
5664 form: FormApi<FormValues>
5765} & FormState<FormValues>
5866
Original file line number Diff line number Diff line change @@ -53,7 +53,9 @@ export interface FormRenderProps<FormValues = AnyObject>
5353 RenderableProps < FormRenderProps < FormValues > > {
5454 form : FormApi < FormValues > ;
5555 handleSubmit : (
56- event ?: React . SyntheticEvent < HTMLFormElement >
56+ event ?: Partial <
57+ Pick < React . SyntheticEvent , 'preventDefault' | 'stopPropagation' >
58+ >
5759 ) => Promise < AnyObject | undefined > | undefined ;
5860}
5961
You can’t perform that action at this time.
0 commit comments