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

Fix #262: Reset Upload dialog when the back button is clicked #268

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions client-src/digitize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});