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

options.clear() NOT works in FileUpload #2026

Closed
godomainz opened this issue May 10, 2021 · 2 comments
Closed

options.clear() NOT works in FileUpload #2026

godomainz opened this issue May 10, 2021 · 2 comments
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@godomainz
Copy link

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Current behavior

I have my FileUpload like below

<FileUpload
                            mode="basic"
                            name="baptism_certificate"
                            accept="image/*"
                            customUpload
                            uploadHandler={onBaptismCertificateUploadAuto}
                            chooseLabel="Browse"
                            maxFileSize={1000000}
                          />

This is my onBaptismCertificateUploadAuto method

const onBaptismCertificateUploadAuto = ({ files, options }) => {
    const [file] = files;
    dispatch(uploadParishionerBaptismCertificate(parishioner.id, file));
    options.clear()
  };

After image uploads. I can see File name on the button disappears but then I get an error like this

TypeError: Cannot set property 'value' of null
FileUpload.clearInputElement
I:/ReactJS Projects/church/frontend/node_modules/primereact/components/fileupload/FileUpload.js:167
  164 | }, {
  165 |   key: "clearInputElement",
  166 |   value: function clearInputElement() {
> 167 |     this.fileInput.value = '';
      | ^  168 |   }
  169 | }, {
  170 |   key: "clearIEInput",
View compiled
FileUpload.clear
I:/ReactJS Projects/church/frontend/node_modules/primereact/components/fileupload/FileUpload.js:411
  408 |       this.props.onClear();
  409 |     }
  410 | 
> 411 |     this.clearInputElement();
      | ^  412 |   }
  413 | }, {
  414 |   key: "choose",

Please tell us about your environment:
OS: Windows 10 Pro
Primereact : 6.3.2
React: 17.0.1

  • Browser: [ Chrome 90.0.4430.93 (Official Build) (64-bit]

  • Language: [TypeScript 4.1.3]

@mertsincan mertsincan added this to the 6.4.0 milestone May 10, 2021
@mertsincan mertsincan self-assigned this May 10, 2021
@mertsincan mertsincan added the Type: Bug Issue contains a defect related to a specific component. label May 10, 2021
@mertsincan
Copy link
Member

So sorry for this mistake :/
Thanks a lot for your report! Fixed for 6.4.0.

For now, please try;

...
import { FileUpload } from 'primereact/fileupload';

function App() {
  // your codes
}

/* Fixed for 6.4.0 */
FileUpload.prototype.clearInputElement = function() {
  if (this.fileInput) {
      this.fileInput.value = '';
  }
}

export default App;

Best Regards,

@godomainz
Copy link
Author

godomainz commented May 10, 2021

So sorry for this mistake :/
Thanks a lot for your report! Fixed for 6.4.0.

For now, please try;

...
import { FileUpload } from 'primereact/fileupload';

function App() {
  // your codes
}

/* Fixed for 6.4.0 */
FileUpload.prototype.clearInputElement = function() {
  if (this.fileInput) {
      this.fileInput.value = '';
  }
}

export default App;

Best Regards,

@mertsincan
How can I get 6.4.0 ?
I'm getting npm ERR! notarget No matching version found for primereact@^6.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

2 participants