From 40765c3883be515645da8ed16a61535569c01428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 6 Nov 2020 12:34:09 +0100 Subject: [PATCH] Fix uploading same file twice in a row in Chromium MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/components/NewMessageForm/NewMessageForm.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index 7632f4476c4..8ff92d62c55 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -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 = '' }, /**