-
Notifications
You must be signed in to change notification settings - Fork 8
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
Closing a Dialog with the default "x" icon triggers onSubmit() #1546
Comments
Hi @joeyamst, thanks for reporting. That certainly looks like a bug. We will look into it and report back. The link to the CodeSandbox leads to a 404 for me, but we can probably reproduce without it. |
@VincentSmedinga Not sure why you get the 404. It is indeed easy to reproduce:
The log "Submit" triggers when closing the Dialog with the "x" icon. |
@joeyamst Me neither – I registered with GitHub and added additional authorization scopes, but I’m unfamiliar with that site. No worries. We’re well underway with a solution in the PR mentioned above. I’ve just invited you to add your feedback, if any. |
@joeyamst We’ve just released @amsterdam/design-system-react v0.11.1 to address this. The close button now calls the dialog’s No changes on your side are necessary. Please let us know whether this indeed resolves the problem. |
@VincentSmedinga After upgrading to 0.11.1 I can confirm the onSubmit() does not get triggered on closing the dialog. Thanks for the quick response! |
Describe the issue
When closing a
Dialog
with the default "x" icon, theonSubmit()
hook that is given as prop to theDialog
will trigger. This is unwanted because the form in my dialog gets submitted without the user wanting to submit it.Summary
The Dialog component contains a
<form>
. When I create a Dialog and give it aonSubmit()
prop, this function will be triggered when I press the "x" icon.Steps to reproduce
(Provide a clear and concise list of steps to reproduce the issue.)
onSubmit()
with some logging codeonSubmit()
function is triggeredHere's a link to a codesandbox: https://codesandbox.io/p/devbox/muddy-forest-n9h9lt?workspaceId=5bdd83a2-36b4-4d1b-acb9-544b42f5ece6
Environment
Checklist
Before submitting your issue, please ensure you have done the following:
Additional notes
It is probably due to how
<form method="dialog">
handles the closing of a dialog, seeing it as a submit.The text was updated successfully, but these errors were encountered: