primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
10.6k stars 4.62k forks source link

FileUpload: clear fn does not clear uploadedFiles #16424

Open playtinum opened 2 months ago

playtinum commented 2 months ago

Describe the bug

When calling the clear method of file upload component that clears the files and sets uploaded files count to 0 but does not clear the uploaded files list, resulting in still seeing the uploded files.

Environment

Angular 18+

Reproducer

No response

Angular version

18.2.0

PrimeNG version

17.18.9

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.14.0

Browser(s)

EverGreen Browsers

Steps to reproduce the behavior

upload files call clear() fn on FileUpload component

Expected behavior

When calling clear all files should be removed

qwadrox commented 1 month ago

@playtinum I believe that this is by design. Check out this example: https://primeng.org/fileupload#template

<ng-template pTemplate="content"
let-files let-uploadedFiles="uploadedFiles"
let-removeFileCallback="removeFileCallback"
let-removeUploadedFileCallback="removeUploadedFileCallback">

The uploadedFiles array serves for a different purpose, to display the completed files. So the uploaded files array should not be cleared after every upload. To clear an uploaded file, we can use: removeUploadedFile On the other hand, setting uploaded files count to 0 arguably ambiguous. They added that here: https://github.com/primefaces/primeng/issues/13566 If I see correctly, uploadedFileCount does not add anything to the functionality because we set it to be equal with the files.length then, right after, set back to 0. So the property could be removed.

github-actions[bot] commented 6 days ago

Due to PrimeNG team's busy roadmap, this issue is available for anyone to work on. Make sure to reference this issue in your pull request. :sparkles: Thank you for your contribution! :sparkles: