Merge pull request #8485 from colinux/fix-combobox-form-having-direct-upload

fix(combobox): let direct upload finish before submitting form
This commit is contained in:
Colin Darie 2023-01-24 10:03:55 +01:00 committed by GitHub
commit e6b29af2ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,7 +15,15 @@ export function useDeferredSubmit(input?: HTMLInputElement): {
const interceptFormSubmit = (event: Event) => {
event.preventDefault();
runCallback();
form.submit();
if (
!Array.from(form.elements).some((e) =>
e.hasAttribute('data-direct-upload-url')
)
) {
form.submit();
}
// else: form will be submitted by diret upload once file have been uploaded
};
calledRef.current = false;
form.addEventListener('submit', interceptFormSubmit);