-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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: pre-trigger form submit in multistep form #32290
Comments
Possible Cause & Solution It looks like the form submission is being triggered prematurely due to how the Potential Fixes: Ensure that clicking "Next" between steps doesn’t accidentally trigger form submission. Instead of changing the Instead of relying on |
@muhammadalmaskhan, yes, delay form attribute update using useEffect helps solving. I did that:
Many thanks, Almas! 🚀 NOTE: One of my ways to solve the issue is updating |
Hi @evgeniyworkbel,
|
Another issue I met (related to submit btn outside form) is not triggering form onSubmit event when Here is sandbox with issue. Main concept to fix it is deferring value for SOLUTIONS:
@muhammadalmaskhan what do you think about this? |
There is multistep form with 3 steps: 1st, 2nd steps don't contain forms and 3rd contains. There is general submit button for all steps: it is located outside steps and connected with 3rd form by its id (button has "form" attribute with the same id as form). Value for button "form" attribute is changing depending on active step.
React version: 18.2.0
Steps To Reproduce
Link to code example: https://codesandbox.io/p/sandbox/pre-trigger-form-validation-react-18-cc3xl5
The current behavior
Form of 3rd step has submitted immediately after transition from 2nd step
The expected behavior
Form of 3rd step will not be submitted immediately after transition from 2nd step and will be submitted only after click submit btn which is connected with this form by id
The text was updated successfully, but these errors were encountered: