Skip to content

[BUG] Unexpected reject message for invalid file type (based on accept) #1221

@pzi

Description

@pzi

Describe the bug
When defining the accept param as per Docs/TypeScript definition:

    accept: {
      'image/jpeg': ['.jpeg', '.png']
    }

The rejected message is File type must be image/jpeg,.jpeg,.png instead of what is expected `File type must be one of x, y, z. Which is not very user friendly, especially as there are no spaces applied.

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/react-dropzone-example-forked-qcic4f?file=/src/App.js
  2. Choose a gif file
  3. See error

Expected behavior
File type must be one of .jpeg, .png.

Screenshots
image

Additional context
It seems the rejected util does not perform as expected with the new accept param/the data it's been given. (https://github.com/react-dropzone/react-dropzone/blob/master/src/utils/index.js#L17-L26)

Would be nice to be able to provide custom error messages to override the OOTB ones.

For reference, in version 11.7.1 of react-dropzone, the rejected error message was better: File type must .jpeg, .png - spaces were applied. I assume v13.0.0 introduced the bug.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions