react-dropzone: isDragReject true for accepted file extension
I have seen this work appropriately when setting the MIME type but has not been working when setting the file extension. I want to set a more specific extension, but for the sake of the bug I have been seeing .png being rejected when choosing to accept .png files. The hidden input is working as expected, but the hover and subsequent event is not working as expected.
React dev tools showing current accept:

Screenshot of rejection:

I apologize if I’ve missed something. I’m looking back at your attr-accept project to trace it back.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 24
This however doesn’t fix the problem for files with unspecified MIME types. Any hints on how to handle that case?
Any chance this issue can be reopened, so no new ones need be created?
@lruckman thx, for those coming here from Google try this
accept=".csv,text/csv"Shouldn’t a combination of mime’s and extensions in the accept list address this?
So I’m thinking this has to do with how
isDragRejectis being set:https://github.com/react-dropzone/react-dropzone/blob/ccb859f1eaa43683952bc4f3d4b6d3283a8582a8/src/index.js#L310-L311
as per the documentation, we’re unable to read the file name mid-drag, only the mime-type. So in cases where we have an
acceptthat isn’t a mime,filesCount > 0will betrue, andisDragAcceptwill befalsebecause of howattr-acceptvalidates the mimes:https://github.com/okonet/attr-accept/blob/master/src/index.js#L24-L33
My initial thoughts are to check what kind of
acceptprop we have (mime or extension) and include that in the setting ofisDragReject, something like:Maybe the test for what kind of
acceptwe have should actually live infileAccepted?How do we feel about this solution?
/cc @rkmarks / @okonet
Thanks @ArtemBernatskyy : You are close to god 😃 It solved my csv issue.
I’ll have some time tomorrow to work on this. Though might have something w/ attr-accept npm module. Not sure. I’ll dig in