Fix uploading same file twice in a row in Chromium

To upload files a hidden file input is "clicked", which shows the
browser dialog to pick the files, and the "change" event of the file
input is listened to to know the selected files.

However, although Firefox always emits the "change" event when files are
selected, Chromium only emits the "change" event if the selected files
have changed since the last time. Due to this if a file was uploaded and
then the same file was tried to be uploaded again nothing happened.

Now the value of the file input is cleared (which also clears the files
from the file input) after the files are handled to ensure that there is
no previous state when the browser dialog is shown again, and thus the
selected files always change.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2020-11-06 12:34:09 +01:00
Родитель 36617f663b
Коммит 40765c3883
1 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -326,6 +326,10 @@ export default {
const files = Object.values(event.target.files)
this.handleFiles(files)
// Clear input to ensure that the change event will be emitted if
// the same file is picked again.
event.target.value = ''
},
/**