Skip to content

Commit

Permalink
fix: remove preview when a user starts selecting a file but then canc…
Browse files Browse the repository at this point in the history
…els (the browser no longer has the file, so we cannot upload it in this case) (#1784)
  • Loading branch information
andrewleith authored Mar 26, 2024
1 parent d22c3fd commit 91c2da4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/assets/javascripts/branding_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
const message = document.querySelector(".preview .message");
const image_slot = document.querySelector(".preview .img");
const preview_heading = document.querySelector("#preview_heading");
const preview_container = document.querySelector(".template_preview");
const brand_name_group = document
.querySelector("#name")
.closest(".form-group");
Expand All @@ -35,6 +36,7 @@
input_img.addEventListener("change", updateImageDisplay);
submit_button.addEventListener("click", validateForm);
input_brandname.addEventListener("change", validateBrand);

// strings
let file_name = window.APP_PHRASES.branding_request_file_name;
let file_size = window.APP_PHRASES.branding_request_file_size;
Expand All @@ -57,8 +59,8 @@

const curFiles = input_img.files;
if (curFiles.length === 0) {
const message = document.createElement("p");
message.textContent = "No files currently selected for upload";
preview_container.classList.add("hidden");
} else {
for (const file of curFiles) {
if (validFileType(file)) {
Expand All @@ -74,9 +76,7 @@
}, ${file_size} ${returnFileSize(file.size)}, ${display_size} ${
img.naturalWidth
} x ${img.naturalHeight}`;
document
.querySelector(".template_preview")
.classList.remove("hidden");
preview_container.classList.remove("hidden");
preview_heading.focus();
};
validateLogo();
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/branding_request.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 91c2da4

Please sign in to comment.