Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileUpload: Ability to display and control error messages #4175

Closed
ImranRawani opened this issue Mar 21, 2023 · 1 comment
Closed

FileUpload: Ability to display and control error messages #4175

ImranRawani opened this issue Mar 21, 2023 · 1 comment
Labels
Type: New Feature Issue contains a new feature or new component request

Comments

@ImranRawani
Copy link

ImranRawani commented Mar 21, 2023

Describe the bug

As described in #4173 , since primereact fileupload component does not have out of the box validation for file format and no of files ,

We had developed custom validation functional component , which was working fine till 7.2.0 release, but after upgrading to 8.7.3 and even tested in 9.2.1, its broken as we have to pass the ref of the file upload to this component and then we are getting errors like : (based on issues #2893 , #3045 , #3043 - shows as fixed but still does not work in 8.7.3 and 9.2.1 )

  1. ref.current.setstate is not a function ,as in below code

fileUploadComponentRef.current.setState({ files: validFiles });

For 1) , we found the alternate solution in 9.2.1, by using fileUploadComponentRef.current.setFiles(validFiles) , but what to do if we cannot upgrade to 9.2.1 and are on version 8.7.3 currently ?

And for the below, when we want to show the error message whenever any validation fails like invalid file is selected , then with 8.7.3 & even 9.2.1, our code is broken and we cannot see messagesUI inside current as we used to see till version 7.2.0.

  1. cannot read show of undefined ( ref.current.messagesUI ) as in below code

fileUploadComponentRef.current.messagesUI.show({
severity: 'error',
summary: ,
});

So how to handle this showing of error messages in 8.7.3 and 9.2.1.
Currently, we are on 8.7.3 and cannot easily upgrade to 9.2.1 , so try to provide fix for both .

Suppose, if I have my own message component - I can show there but some error messages like in a) below (coming out of the box ) will come at one place and others which are handled by my custom code will come at another place -which is inconsistent ?

a) with maxFileSize prop and corresponding message props like invalidFileSizeMessageDetail & invalidFileSizeMessageSummary configured, fileupload component will take care of showing the error message as soon as we select the files in a particular place which I assume is the messagesUI in version 7.2.0

Reproducer

No response

PrimeReact version

8.7.3, 9.2.1

React version

17.x

Language

ES6

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@ImranRawani ImranRawani added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 21, 2023
@ImranRawani ImranRawani changed the title Component: Title Unable to display validation messages in fileUpload component Mar 21, 2023
@melloware melloware added Type: New Feature Issue contains a new feature or new component request and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Mar 21, 2023
@melloware melloware changed the title Unable to display validation messages in fileUpload component FileUpload: Ability to display and control error messages Mar 21, 2023
@habubey
Copy link
Contributor

habubey commented Oct 30, 2023

Issue tracker is used for defects only as part of our commitment to quality and continuous improvement in all areas. Enhancements are collected as valuable community feedback and managed internally so moving this enhancement ticket to our internal project management backlog.

@habubey habubey closed this as completed Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

3 participants