primefaces / primefaces/primereact

FileUpload: Set Badges to error in customUpload if file is not valid due to custom validation

Open
#7,054 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Resolution: Workaround Type: Enhancement
Dominant language
CSS
Stars
8.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

During the custom upload, I first upload two files and check their names according to certain conventions. These files do not pass the test and their badge remains on “Pending”.

If I now upload a correct file, the two invalid files are removed from the upload field and only the valid file remains, whose badge is set to “Completed”.

However, the desired behavior is as follows:

  • All files that already exist in the upload field remain there.

  • Files that pass the validation are given the “Completed” badge.

  • Files that do not pass validation receive the “Error” badge.

Is there a way to implement this behavior?

Reproducer

https://stackblitz.com/edit/stackblitz-starters-3u6avq?file=src%2FApp.tsx

System Information

System:
OS: Windows 11 10.0.22621
CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1355U
Memory: 16.85 GB / 31.69 GB
Binaries:
Node: 21.6.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.5.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (127.0.2651.74)
Internet Explorer: 11.0.22621.3527
npmPackages:
primereact: ^10.7.0 => 10.7.0
react: ^18.2.0 => 18.3.1

Steps to reproduce the behavior
  1. choose one .png and one .jpg file
  2. click on upload
Expected behavior

the .jpg files badge needs to get to error.

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 StackBlitz reproducer in src/App.tsx and reproduce the custom upload using one .png and one .jpg file. Inspect the FileUpload custom-upload behavior; done means existing files remain, valid files show “Completed,” and invalid files show “Error” rather than being removed or left pending.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.