Skip to content

Commit 2133eb6

Browse files
authored
Programmatic submit does not work in React 17 (#900)
* Add bubbles:true to event * Add bubbles:true to event
1 parent b3c79b8 commit 2133eb6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ trigger React's event handlers.
5555

5656
<button onClick={() => {
5757
document.getElementById('myForm')
58-
.dispatchEvent(new Event('submit', { cancelable: true })) //
58+
.dispatchEvent(new Event('submit', { cancelable: true, bubbles:true })) //
5959
}}>Submit</button>
6060

6161
<form id="myForm" onSubmit={handleSubmit}>

examples/external-submit/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const App = () => {
3232
// https://github.com/facebook/react/issues/12639#issuecomment-382519193
3333
document
3434
.getElementById('exampleForm')
35-
.dispatchEvent(new Event('submit', { cancelable: true }))
35+
.dispatchEvent(new Event('submit', { cancelable: true, bubbles:true }))
3636
}
3737
>
3838
External Submit via <code>document.getElementById()</code>

0 commit comments

Comments
 (0)