Skip to content

Commit

Permalink
fix(file-upload): item delete trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Jan 14, 2025
1 parent 79fd827 commit b7ad1ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-penguins-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/file-upload": patch
---

Fix issue where rejected files could not be deleted using the item delete trigger.
6 changes: 4 additions & 2 deletions packages/machines/file-upload/src/file-upload.machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ export function machine(userContext: UserDefinedContext) {
}
},
removeFile(ctx, evt) {
const nextFiles = ctx.acceptedFiles.filter((file) => file !== evt.file)
ctx.acceptedFiles = ref(nextFiles)
const files = Array.from(ctx.acceptedFiles.filter((file) => file !== evt.file))
const rejectedFiles = Array.from(ctx.rejectedFiles.filter((item) => item.file !== evt.file))
ctx.acceptedFiles = ref(files)
ctx.rejectedFiles = ref(rejectedFiles)
invoke.change(ctx)
},
clearRejectedFiles(ctx) {
Expand Down

0 comments on commit b7ad1ef

Please sign in to comment.