erykpiast / bs-react-dropzone

ReasonML bindings for react-dropzone library
MIT License
5 stars 1 forks source link

Unifying dragging status property #4

Open erykpiast opened 5 years ago

erykpiast commented 5 years ago

react-dropzone exposes three booleans representing (potentially) single state: isDragActive, isDragAccept and isDragReject. It may be modeled with variants as Inactive (Accepted | Rejected) | Active. Unified property may be called dragStatus.

The hypothesis has to be verified. What happens when some files were accepted and some of them rejected? Does the possibility exist that accepted or rejected is true when active is true?

erykpiast commented 5 years ago

According to this code and this test show that there is one single case when active status may be both active and rejected - all files were valid but there were more then one of those and multiple flag was set to false.

Maybe it's good idea to introduce rejection reason concept? Inactive (Accepted | Rejected(WrongFormat | TooMany)) | Active.

Funny thing is, if some file exceeds maxSize or is smaller than minSize, it's added to rejectedFiles array but isDragReject isn't set to true. EDIT: it's because these are dragging-in-progress flags, while acceptedFiles and rejectedFiles are post-drag collections. According to this issue there is no way to check file size before dropping it.