Skip to content

Commit

Permalink
Fix for new submit() method (PR rjsf-team#1058) also submitting the H…
Browse files Browse the repository at this point in the history
…TML form

..., navigating away from current page at least in Firefox. Reason:
dispatched event was not cancelable, so preventDefault in onSubmit
couldn't cancel it.

Links:

* <https://stackoverflow.com/a/40916998>
* <https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable>
  • Loading branch information
sbusch committed Oct 26, 2018
1 parent b3fb5ae commit ed3ecd4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default class Form extends Component {

submit() {
if (this.formElement) {
this.formElement.dispatchEvent(new Event("submit"));
this.formElement.dispatchEvent(new Event("submit", { cancelable: true }));
}
}

Expand Down

0 comments on commit ed3ecd4

Please sign in to comment.