Skip to content

Commit

Permalink
Fix outdated event object, upload editors (jdorn#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdruzhynin authored Apr 9, 2020
1 parent 3152967 commit cfec910
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/editors/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class UploadEditor extends AbstractEditor {
let fr = new window.FileReader()
fr.onload = (evt) => {
this.preview_value = evt.target.result
this.refreshPreview(e)
this.refreshPreview(files)
this.onChange(true)
fr = null
}
Expand Down Expand Up @@ -196,15 +196,14 @@ export class UploadEditor extends AbstractEditor {
this.theme.afterInputReady(this.input)
}

refreshPreview (e) {
refreshPreview (files) {
if (this.last_preview === this.preview_value) return
this.last_preview = this.preview_value

this.preview.innerHTML = ''

if (!this.preview_value) return

const files = e.target.files || e.dataTransfer.files
const file = files[0]

/* mime type extracted from file data. More exact than the one in the file object */
Expand Down

0 comments on commit cfec910

Please sign in to comment.