diff --git a/client-src/digitize/index.js b/client-src/digitize/index.js index e03524d5..a5134805 100644 --- a/client-src/digitize/index.js +++ b/client-src/digitize/index.js @@ -29,3 +29,17 @@ document.forms.namedItem("upload").onsubmit = () => { setDisabled("submitBtn", true); setIsBusy("submitBtn", true); }; + +// In case the page is newly loaded, reset the upload button, the spinner, and the upload field. +// This prevents unexpected behaviour when clicking the back button after an upload. +window.addEventListener("pageshow", () => { + setDisabled("submitBtn", true); + setIsBusy("submitBtn", false); + + // Remove all previously selected files. The used file selector (filebokz) seems not to + // provide a working solution to remove all selected files at once. + const removeButtons = document.getElementsByClassName("remove"); + for (let i = removeButtons.length - 1; i >= 0; i--) { + removeButtons[i].click(); + } +});