Skip to content

Commit

Permalink
Fix Array.from syntax in nonmultiple file upload (#2357)
Browse files Browse the repository at this point in the history
- Fix Array.from syntax in nonmultiple file upload as Array.from(<non-array or string>) returns an empty array which is the case when a file is selected from an input element (when multiple attribute isn't  supported) which can be found in Array.from(element.files[0]) -> results in an empty array.
  • Loading branch information
omar-ahmed42 authored Nov 29, 2024
1 parent a5ba6c4 commit 99d481d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/resources/static/js/fileInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function setupFileInput(chooser) {
if (element instanceof HTMLInputElement && element.hasAttribute("multiple")) {
allFiles = isDragAndDrop ? allFiles : [... allFiles, ... element.files];
} else {
allFiles = Array.from(isDragAndDrop ? allFiles : element.files[0]);
allFiles = Array.from(isDragAndDrop ? allFiles : [element.files[0]]);
}

if (!isDragAndDrop) {
Expand Down

0 comments on commit 99d481d

Please sign in to comment.