react-dropzone icon indicating copy to clipboard operation
react-dropzone copied to clipboard

[BUG] File picker not showing on Chrome/Edge when extension with underscore exists

Open xennialex opened this issue 3 years ago • 6 comments

Describe the bug In Google Chrome and Microsoft Edge it's currently not possible to show the file picker if accept has any file extension containing an underscore (e.g. '.zip_1'). It still works in Mozilla Firefox.

It's showing TypeError: Failed to execute 'showOpenFilePicker' on 'Window': Extension '.zip_1' contains invalid characters. in the console output if I click on the dropzone.

To Reproduce Here is a small code sample:

import {useDropzone} from 'react-dropzone'

export default function Home() {

  const { getRootProps, getInputProps } = useDropzone({
    accept: { 'application/zip': ['.zip', '.zip_1'] }
  })

  return (
    <>
      <div {...getRootProps()} id="upload-file" style={{width: '200px', height: '200px'}}>
        <input {...getInputProps()} />
      </div>
    </>
  )
}

Expected behavior Should show the file picker dialog

Screenshots image

Desktop:

  • OS: Windows 11
  • Browser Chrome; Edge
  • Version 108.0.5359.95 (Official Build) (64-bit); 107.0.1418.56 (Official build) (64-bit)

xennialex avatar Dec 06 '22 08:12 xennialex

We're having the exact same issue. We did find a temporary workaround...if you don't specify the MIME type, it seems to work fine: image

joebochill avatar Feb 24 '23 16:02 joebochill

@joebochill - does it still show that option in the file picker? For me it filters that option out, and warns in the console.

bensewell avatar Mar 02 '23 10:03 bensewell

I've raised this bug on Chromium:

https://bugs.chromium.org/p/chromium/issues/detail?id=1420912

bensewell avatar Mar 02 '23 10:03 bensewell

@bensewell yes, I do get a warning in the console, but I am able to select the file from the picker window (in Chrome, that's all I checked).

On a mac, the file picker window defaults to "JPEG Images", so I have to toggle the dropdown to allow "All Files", but then I am able to select the files with the underscore in the extension: image

joebochill avatar Mar 02 '23 22:03 joebochill

I apologize in advance for commenting in an old ticket, but does anyone know under what circumstances this bug appears? We're trying to work around it, but cannot reproduce it locally and it's clearly not 100% of users... our testing shows only a relatively small % of users seeing this issue (we also have users uploading CAD files in x_t and x_b format).

bsmedberg-xometry avatar Dec 18 '23 17:12 bsmedberg-xometry