Skip to content
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

Submit events propagates to other forms without the ability to prevent it #549

Closed
felixmosh opened this issue Aug 24, 2020 · 0 comments
Closed

Comments

@felixmosh
Copy link
Contributor

felixmosh commented Aug 24, 2020

I have a page with a main form, which uses onValidSubmit callback.
And a second sub form which is inside a modal (not related to the main form).

When I submit (via button) the modal form, the main form gets the submit event as well.
I've debugged it and found out that the issue is that the modal event form is propagated to the main one (this is how events works in React).

The problem is that I don't have the event in order to call stopPropagation on it.

https://codesandbox.io/s/fervent-dubinsky-pw99c?file=/src/App.tsx

Possible solution is to pass the submit event to the onValidSubmit/onInvalidSubmit/onSubmit as the last argument

More info, https://reactjs.org/docs/portals.html#event-bubbling-through-portals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant