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

Form with an Uppy-element without uploads must be submitted twice #5278

Closed
2 tasks done
joostdebruijn opened this issue Jun 25, 2024 · 1 comment · Fixed by #5299
Closed
2 tasks done

Form with an Uppy-element without uploads must be submitted twice #5278

joostdebruijn opened this issue Jun 25, 2024 · 1 comment · Fixed by #5299
Labels

Comments

@joostdebruijn
Copy link

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

https://stackblitz.com/edit/vitejs-vite-bj2dju?file=main.js

Steps to reproduce

  1. Open the example application
  2. Don't upload a file and press submit
  3. The form will not be submitted - press submit once more, the form will be submitted

However, it will submit the form directly when you upload a file:

  1. Open the example application
  2. Upload a file and press submit
  3. The form will be submitted directly

Please note the form has both submitOnSuccess and triggerUploadOnSubmit. See my previously (probably related) issue #5057 and PR where this behavior has been introduced: #5058

Expected behavior

The form should be submitted directly, even when there are no files uploaded.

Actual behavior

It looks like it has to do with the logic in the handleFormSubmit-function:

https://github.com/transloadit/uppy/blob/main/packages/%40uppy/form/src/index.ts#L91-L93

The ev.preventDefault() prevents the form from being submitted. I assume that, because there isn't an upload completing, the submission of the form will never be called, however the Uppy-element gets completed and therefore the next click on the submit button of the form will succeed because the if condition at line 92 will not be hit.

@aduh95
Copy link
Member

aduh95 commented Jun 27, 2024

I can reproduce. FWIW the issue is easier to see if you put the <form> inside a <dialog> element:

  <dialog open>
    <form method="dialog">
      <div id="app"></div>
      <input type="submit">
    </form>
  </dialog>

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

Successfully merging a pull request may close this issue.

2 participants