Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uploading same file twice in a row in Chromium #4550

Merged

Conversation

danxuliu
Copy link
Member

@danxuliu danxuliu commented Nov 6, 2020

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.

How to test

  • Open a conversation in Chromium
  • Upload a file (or dismiss the Talk dialog to confirm the files to upload)
  • Try to upload the same file again

Result with this pull request

The Talk dialog to confirm the files is shown and the file can be uploaded.

Result without this pull request

The browser dialog to select the files is shown, but not the Talk dialog to confirm the files.

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>
@danxuliu
Copy link
Member Author

danxuliu commented Nov 6, 2020

/backport to stable20

@danxuliu
Copy link
Member Author

danxuliu commented Nov 6, 2020

/backport to stable19

Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested with Chromium, works 👍

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🙏

@skjnldsv
Copy link
Member

skjnldsv commented Nov 6, 2020

Fixes #3904

@skjnldsv skjnldsv linked an issue Nov 6, 2020 that may be closed by this pull request
@PVince81 PVince81 merged commit 1d1f2cc into master Nov 9, 2020
@PVince81 PVince81 deleted the fix-uploading-same-file-twice-in-a-row-in-chromium branch November 9, 2020 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attachment gets re-uploaded if you close/open the talk tab
3 participants