Skip to content

Commit 379755c

Browse files
ineenthoerikras
authored andcommitted
Fix support for nested forms by calling stopPropagation (#289)
1 parent cef75f2 commit 379755c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ReactFinalForm.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ class ReactFinalForm extends React.Component<Props, State> {
101101
}
102102

103103
handleSubmit = (event: ?SyntheticEvent<HTMLFormElement>) => {
104-
if (event && typeof event.preventDefault === 'function') {
104+
if (event) {
105105
// sometimes not true, e.g. React Native
106-
event.preventDefault()
106+
if (typeof event.preventDefault === 'function') {
107+
event.preventDefault()
108+
}
109+
if (typeof event.stopPropagation === 'function') {
110+
// prevent any outer forms from receiving the event too
111+
event.stopPropagation()
112+
}
107113
}
108114
return this.form.submit()
109115
}

0 commit comments

Comments
 (0)