fix(combobox): let direct upload finish before submitting form
Quand un form pour lequel on intercepte le submit a un direct upload, on laisse le direct upload gérer le submit manuellement pour attendre la fin de l'upload ; autrement le form est parfois soumis sans la référence au fichier, ce qui provoque des erreurs rails `InvalidSignature`.
This commit is contained in:
parent
4e0f83aad6
commit
d7f170b57a
1 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue