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

On Firefox ver 112 (64 bit) dialog doesn't open

Open GlutVonSmark opened this issue 3 years ago • 14 comments

Describe the bug On Firefox browser version 112 dialog doesn't open. Works on Chrome and Edge without issues

To Reproduce Here's the code

const { getRootProps, open } = useDropzone({ multiple: false, accept: { 'text/csv': ['.csv', '.CSV'], }, maxSize: maxSize, onDrop: (acceptedFiles, rejectedFiles) => { ...not related to opening the dialog } });

Have a button with onClick={open} and also a div that opens a dialog when clicked on other browsers

GlutVonSmark avatar Apr 17 '23 13:04 GlutVonSmark

Which react-dropzone version are you using? This might be related to https://github.com/react-dropzone/react-dropzone/issues/1239#issuecomment-1279389115 . Upgrading to v14.2.3 would solve it

fahmilatib avatar Apr 26 '23 12:04 fahmilatib

facing same issue

Rahulk4128 avatar May 02 '23 15:05 Rahulk4128

I'm using the latstes version "react-dropzone": "^14.2.3",

GlutVonSmark avatar May 03 '23 07:05 GlutVonSmark

even using the latest version it is not working. it is woking fine with google chrome.

Rahulk4128 avatar May 04 '23 05:05 Rahulk4128

This is also broken for me on 14.2.3

Edit: it does work in the example, so it must be us :) https://react-dropzone.js.org/#section-basic-example

StampixSMO avatar May 16 '23 13:05 StampixSMO

Destructure getInputProps from the hook. Then add to your dropzone: <input {...getInputProps()} />. That should fix it.

Dropzone tries to use the new File System Access API if supported. It doesn't need a <input type="file" ... /> to open the dialog.

However if you set useFsAccessApi to false on Chrome or use Firefox/Safari (where the file access api isn't supported at all), it needs an <input type="file" /> to open the dialog.

Brqqq avatar May 22 '23 13:05 Brqqq

Thanks @Brqqq

For the sake of everyone else: my mistake was stupid. I abstracted react-dropzone away in a hook, but made a mistake where the open() function was not bound to any <input /> element (it was never rendered). Works fine now!

StampixSMO avatar May 22 '23 14:05 StampixSMO

Destructure getInputProps from the hook. Then add to your dropzone: <input {...getInputProps()} />. That should fix it.

Dropzone tries to use the new File System Access API if supported. It doesn't need a <input type="file" ... /> to open the dialog.

However if you set useFsAccessApi to false on Chrome or use Firefox/Safari (where the file access api isn't supported at all), it needs an <input type="file" /> to open the dialog.

What if i'm not using an input? I'm having a div for the drag and drop functionality. Can't set type="file" on a div. I'm assuming I can't open the dialog with a div click without FS Access API

GlutVonSmark avatar Jun 26 '23 09:06 GlutVonSmark

What if i'm not using an input? I'm having a div for the drag and drop functionality. Can't set type="file" on a div. I'm assuming I can't open the dialog with a div click without FS Access API

The input isn't visible. It's only there so you have a way to open the dialog. Otherwise you have to use the FS access API which is still poorly supported.

Brqqq avatar Jun 26 '23 12:06 Brqqq

ok that works. Should I close this one? I mean we have a workaround and the problem is with the browser support. Maybe just need to update docs so people are aware of this

GlutVonSmark avatar Jun 27 '23 10:06 GlutVonSmark

I encountered this issue as well. File browser button would work on chrome/edge but not firefox.

In my case, the code I was working with had multiple input elements (with the {...getInputProps()}) throughout the component containing the dropzone. I removed the extraneous inputs, leaving only one at the 'top' level, and the issue went away.

aventide avatar Aug 29 '23 18:08 aventide

in my case , i had conditionally rendered <input ref={ref} onBlur={onBlur} {...getInputProps()} /> that is becomes an issue in firefox. the solution is so simple it always should be on the DOM if you want to open to work

phani1585 avatar Oct 19 '23 15:10 phani1585

Destructure getInputProps from the hook. Then add to your dropzone: <input {...getInputProps()} />. That should fix it.

Dropzone tries to use the new File System Access API if supported. It doesn't need a <input type="file" ... /> to open the dialog.

However if you set useFsAccessApi to false on Chrome or use Firefox/Safari (where the file access api isn't supported at all), it needs an <input type="file" /> to open the dialog.

Turns out you can hide the input and it still works. :D

<div>
            <input type="file" {...getInputProps()} style={{ display: "none" }} />

            <div
                {...getRootProps({ className: "dropzone" })}
                style={{ border: "1px solid lightgray", padding: 10, borderRadius: 10 }}
            >
                <p style={{ cursor: "default" }}>Click or drag file here to upload</p>
            </div>
</div>

asos-aaroncooper avatar Jun 17 '24 11:06 asos-aaroncooper