primeng icon indicating copy to clipboard operation
primeng copied to clipboard

FileUpload: Empty template not working

Open alainosorio opened this issue 1 year ago • 5 comments

Describe the bug

FileUpload empty template was working in previous version 17. FileUpload empty template is not working in current version 18-19.

It is also not working in the primeng examples.

Working here: https://v17.primeng.org/fileupload#template image

Not working here: https://primeng.org/fileupload#template image

Environment

windows 11

Reproducer

No response

Angular version

19.0.4

PrimeNG version

19

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

22.10.0

Browser(s)

Chrome

Steps to reproduce the behavior

No response

Expected behavior

FileUpload empty template should be working with custom content like previous version 17

alainosorio avatar Dec 19 '24 18:12 alainosorio

Will this be back-ported to PrimeNG 18 LTS?

awdorrin avatar Feb 20 '25 20:02 awdorrin

@awdorrin and anyone looking to make the "empty" template work in v18: the fix introduced in v19:

@if ((emptyTemplate || _emptyTemplate) && !hasFiles() && !hasUploadedFiles()) has not been implemented in v18. In v18, the old code remains: @if (emptyTemplate && _emptyTemplate && !hasFiles() && !hasUploadedFiles()) This means you need to use both approaches for template to make it work. Here's a hackfix which worked for me in v18.0.2:

<p-fileupload ... >
  <ng-template pTemplate="empty" #empty>YAY! Empty state works!</ng-template>
</p-fileupload>

Both pTemplate="empty" and #empty are necessary in the template until this issue is resolved in v18.

PeterSisovsky avatar Mar 19 '25 23:03 PeterSisovsky

@PeterSisovsky thanks, i will try that out tomorrow!

awdorrin avatar Mar 19 '25 23:03 awdorrin

Your suggestion works great to show the empty template, thanks again. I had modified my implementation to always show 'Drag and drop files to here to upload' with the following code

          <p-fileupload name="accessRequestAttachment"
                        [multiple]="true"
                        [customUpload]="true"
                        (uploadHandler)="onFileUploadClicked($event)"
                        (onSelect)="onSelectFile($event)"
                        maxFileSize="1000000"
                        mode="advanced">
            <ng-template #content>
              <div>Drag and drop files to here to upload.</div>
            </ng-template>            
          </p-fileupload>

awdorrin avatar Mar 20 '25 16:03 awdorrin

Thanks for the update. Glad it worked for you. Have a nice day!

PeterSisovsky avatar Mar 20 '25 16:03 PeterSisovsky