-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Using dispatchEvent 'submit' CustomEvent failure to trigger form onSubmit #20151
Comments
same too 🤩 |
Thanks for the report. A submit event has to bubble: https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event. React handled the non-bubbling case in 16 but I think the change in behavior is correct. What's the reason to not let this event bubble and use a But you don't need to dispatch custom events. If you convert your |
@eps1lon Hi, my scenario is click on a button outside the form to trigger a submit. |
I hope you're aware that dispatching the submit events does not trigger form validation. You could get a ref to the form and run What's the reason you need a non-bubbling CustomEvent? Note: Though it still might be problematic that non-bubbling submit events don't work since submit events don't bubble by spec. Though they might in all the supported browsers. |
Thank you for your answer. |
Added bubbles to Event in submit method facebook/react#20151 (comment)
Add bubbles to Event in submit method facebook/react#20151
React version: 17+
Steps To Reproduce
1.form add onSubmit props
2.dispatchEvent a CustomEvent with 'submit' name
Link to code example: https://codesandbox.io/s/admiring-almeida-3b26k?file=/src/App.js
The current behavior
failure to trigger form onSubmit
The expected behavior
onSubmit can be successfully triggered until 17.
The text was updated successfully, but these errors were encountered: