primefaces / primefaces/primereact

FileUpload: FileUploadSelectEvent `files` property contains wrong values

Open
#8,242 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Needs Triage
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:

  1. Upload a 400KB image file.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.