[ENHANCEMENT] Allow to group mime types in `accept`
#1 189 ouverte le 4 mai 2022
Description
Is your feature request related to a problem? Please describe.
A side-effect of version 13.0.0 is that now each mime type defined in the accept option becomes a separate entry in the file picker.
window.showOpenFilePicker expects an array of entries where we can combine mime types and give a custom description, but AFAIK react-dropzone doesn't allow this and will always create an array entry for each mime type.
Describe the solution you'd like
One solution could be to let users pass an array of objects to accept, which would have the same shape as the types option of window.showOpenFilePicker:
const dropzone = useDropzone({
accept: [
{
description: 'All supported images',
accept: {
'image/jpeg': ['.jpg', '.jpeg'],
'image/png': [],
}
},
{
description: 'JPEG images',
accept: {
'image/jpeg': ['.jpg', '.jpeg'],
}
},
{
description: 'PNG images',
accept: {
'image/png': [],
}
},
]
})
Result:

Describe alternatives you've considered
Otherwise, a new option could be added for this, but it would be ambiguous if someone also passed accept at the same time.