Explorar el Código

@uppy/drag-drop - made .onBeforeFileAdded() be called twice even if file is the same

Evgenia Karunus hace 5 años
padre
commit
c52f35dee0
Se han modificado 1 ficheros con 5 adiciones y 5 borrados
  1. 5 5
      packages/@uppy/drag-drop/src/index.js

+ 5 - 5
packages/@uppy/drag-drop/src/index.js

@@ -105,6 +105,10 @@ module.exports = class DragDrop extends Plugin {
         // Nothing, restriction errors handled in Core
       }
     })
+
+    // ___Why not use value="" on <input/> instead?
+    //    Because if we use that method of clearing the input, Chrome will not trigger onChange={} if we drop the same file twice (Issue #768).
+    event.target.value = null
   }
 
   render (state) {
@@ -140,11 +144,7 @@ module.exports = class DragDrop extends Plugin {
               name={this.opts.inputName}
               multiple={restrictions.maxNumberOfFiles !== 1}
               accept={restrictions.allowedFileTypes}
-              ref={(input) => {
-                this.input = input
-              }}
-              onchange={this.handleInputChange}
-              value="" />
+              onchange={this.handleInputChange} />
             {this.i18nArray('dropHereOr', {
               browse: <span class="uppy-DragDrop-dragText">{this.i18n('browse')}</span>
             })}