quasar
quasar copied to clipboard
Dialog plugin 'file' prompt does not work in Firefox
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?
- Open FIREFOX and browse to the codepen
- Click the PROMPT button
- select a file
- click ok
- Note that the difference between the
validationandfinalresults - 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
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 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!