primefaces / primefaces/primereact
FileUpload: FileUploadSelectEvent `files` property contains wrong values
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 8.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
The FileUpload onBeforeSelect and onSelect callbacks receive an incorrectly populated FileUploadSelectEvent.
Its files property contains the same values returned by getFiles() on the component ref, instead of only the newly selected files.
This makes it impossible to distinguish between newly and previously selected files.
In onBeforeSelect, the situation is even worse: the files property does not contain the newly selected files at all, since they have not yet been added.
Reproducer
No response
System Information
primereact: "^10.9.6"
react: "19.1.0"
Steps to reproduce the behavior
You can reproduce this in the "Template" example from the online demo:
https://primereact.org/fileupload/#template
Steps:
- Upload a 400KB image file.
- Then upload a 10KB image file.
Observed result:
The total file size reported is 800KB, because the onSelect implementation assumes files contains only the newly added files.
Expected behavior
files should contain only the newly selected files, allowing actions to be taken with respect to the new selection.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the FileUpload component and its onBeforeSelect and onSelect callbacks, then reproduce the behavior using the Template example and the two-file upload steps described in the issue. Trace how the FileUploadSelectEvent files property is populated and verify that each callback receives only the newly selected files, including before they are added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100