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

submitOnSuccess: form.submit vs other methods for event triggering #4663

Closed
2 tasks done
chriso0710 opened this issue Sep 5, 2023 · 4 comments · Fixed by #4852
Closed
2 tasks done

submitOnSuccess: form.submit vs other methods for event triggering #4663

chriso0710 opened this issue Sep 5, 2023 · 4 comments · Fixed by #4852
Labels

Comments

@chriso0710
Copy link

chriso0710 commented Sep 5, 2023

Initial checklist

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

Problem

I use submitOnSuccess on the form plugin. When enabled uppy calls

this.form.submit()

If you - like me - happen to have your own form submit event handler, which does additional stuff, this handler won't get triggered by uppy.

Solution

So what about calling something like

this.form.dispatchEvent(new Event('submit'))

or

this.form.requestSubmit()

(on modern browsers)
which should both send the submit event.

Does that make sense, what do you think? Or am I missing something here?

Alternatives

ATM I do not see any other option to get your own submit handler triggered by uppy.

@Murderlon
Copy link
Member

If that works for both cases then I think it's good! Willing to make a PR and test it?

@chriso0710
Copy link
Author

Yes, I would, this will take a few days, though...

Any more suggestions, what browser compatiblity do we need? see https://caniuse.com/mdn-api_htmlformelement_requestsubmit
Should we test for browser compatibility like this?

if (form.requestSubmit) {
  form.requestSubmit();
} else {
  form.submit();
}

@Murderlon
Copy link
Member

We no longer support IE so support seems fine 👍

@chriso0710
Copy link
Author

Great, thank you @Murderlon! I am sorry for letting this slip through...

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