quasar icon indicating copy to clipboard operation
quasar copied to clipboard

Dialog plugin 'file' prompt does not work in Firefox

Open david-mohr opened this issue 3 years ago • 0 comments

What happened?

When creating a $q.dialog({ prompt }) and setting prompt.type to file, onOk, Firefox does not return the selected file, instead returning an empty file list (tested using version 103.0.1). Strangely enough, isValid gets a valid copy of the File object, but it isn't returned to onOk. Works as expected in Chrome. Tested on Mac and Linux.

What did you expect to happen?

The selected File object is returned to onOk

Reproduction URL

https://codepen.io/morloch/pen/GRxGPJJ

How to reproduce?

  1. Open FIREFOX and browse to the codepen
  2. Click the PROMPT button
  3. select a file
  4. click ok
  5. Note that the difference between the validation and final results
  6. Repeat steps 2-4 in CHROME and note the final output

Flavour

Quasar CLI with Webpack (@quasar/cli | @quasar/app-webpack)

Areas

Plugins (quasar), SPA Mode

Platforms/Browsers

Firefox

Quasar info output

Operating System        Linux(5.15.59-1-MANJARO) - linux/x64
NodeJs                  14.19.3

Global packages    
  NPM                   6.14.17
  yarn                  1.22.18
  @quasar/cli           1.3.2
  @quasar/icongenie     Not installed
  cordova               Not installed

Relevant log output

No response

Additional context

No response

david-mohr avatar Aug 09 '22 02:08 david-mohr

It looks like Firefox has a funny idea to clear the FileList when the input is destroyed. There is nothing we can do while still keeping the model as a FileList.

But you can save the file in the validation callback and use it in the onOk

https://codepen.io/pdanpdan/pen/XWEBqNY

You can see there that the files is cleared, so you must make an array clone of it, or save the individual files.

pdanpdan avatar Aug 10 '22 11:08 pdanpdan

@pdanpdan Thanks, the workaround we have in place is similar to what you suggest: capture the file in the validation and use it if the FileList is empty in onOk. I appreciate you taking a look!

david-mohr avatar Aug 10 '22 23:08 david-mohr