Skip to content

Commit

Permalink
fix(toolkit): only call onSuccess callback when there are valid files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-Zayne committed Nov 22, 2024
1 parent af4fbb5 commit 8d237d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-kangaroos-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zayne-labs/toolkit": patch
---

fix(toolkit): only call onSuccess callback when there are valid files
10 changes: 6 additions & 4 deletions packages/toolkit/src/core/handleFileValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ const handleFileValidation = (options: FileValidationOptions) => {
validFilesArray.push(file);
}

onSuccess?.({
acceptedFiles: validFilesArray,
message: `Uploaded ${validFilesArray.length} file${validFilesArray.length > 1 ? "s" : ""}!`,
});
if (validFilesArray.length > 0) {
onSuccess?.({
acceptedFiles: validFilesArray,
message: `Uploaded ${validFilesArray.length} file${validFilesArray.length > 1 ? "s" : ""}!`,
});
}

return validFilesArray;
};
Expand Down

0 comments on commit 8d237d3

Please sign in to comment.