SAP / ui5-webcomponents-react

A wrapper implementation for React of the UI5 Web Components that are compliant with the SAP Fiori User Experience
https://sap.github.io/ui5-webcomponents-react/
Apache License 2.0
444 stars 100 forks source link

File Uploader: Does not allow sameFileUpload #6381

Closed devanshitrivedi closed 1 month ago

devanshitrivedi commented 1 month ago

Describe the bug

I'm working with the File Uploader component from ‘ui5-webcomponents-react’ (link). We need to enable the upload of the same file multiple times, as users have the option to remove and re-upload files (see attached screenshot).

Currently, I've noticed that if a file is uploaded and then the same file is uploaded again, the onChange method isn't triggered. Is there a workaround for this issue?

Isolated Example

No response

Reproduction steps

  1. Use the File Uploader component from ‘ui5-webcomponents-react’
  2. Enable 'hideInput' and pass a onChange method
  3. Upload a file.. Try uploading the same file again.. onChange method is not called.

Expected Behaviour

On change method is called when same file is uploaded again. Or make a prop available in FileUploader component which allows this functionality. Something similar to this: https://github.com/SAP/openui5/blob/master/src/sap.ui.unified/src/sap/ui/unified/FileUploader.js#L133

Screenshots or Videos

https://github.com/user-attachments/assets/c22a0808-e20c-4c7e-8ef0-08b21bb4cd89

UI5 Web Components for React Version

^1.27.1

UI5 Web Components Version

NA

Browser

Chrome

Operating System

No response

Additional Context

No response

Relevant log output

No response

Organization

No response

Declaration

Lukas742 commented 1 month ago

Hi @devanshitrivedi

Please always try to provide an isolated example so the issue can be processed faster, as this saves us from having to recreate it ourselves.

The onChange event is only triggered when the input value changes. This applies to native input elements as well as the FileUploader web component. To resolve this, you can reset the value prop when a file is removed: https://stackblitz.com/edit/ui5wcr-v1-8qstbs?file=src%2FApp.tsx,package.json

devanshitrivedi commented 1 month ago

Thank you!