GwtMaterialDesign / gwt-material-addins

Custom Components for gwt-material.
https://gwtmaterialdesign.github.io/gmd-addins-demo/
Apache License 2.0
35 stars 46 forks source link

[2.1] MaterialFileUploader - If a file is loaded two times, in second time the event is not call #186

Open richelivargas opened 7 years ago

richelivargas commented 7 years ago

If a file is loaded two times, in second time the event is not call. It occurs when the file is loaded by click event (hiddenFileInput). In second time the change event is not call because is the same file.

In dropzone.js

Original

return _this.hiddenFileInput.addEventListener("change", function() {
              var file, files, _i, _len;
              files = _this.hiddenFileInput.files;
              if (files.length) {
                for (_i = 0, _len = files.length; _i < _len; _i++) {
                  file = files[_i];
                  _this.addFile(file);
                }
              }
              _this.emit("addedfiles", files);
              return setupHiddenFileInput();
            });

My solution

return _this.hiddenFileInput.addEventListener("click", function() {

                _this.hiddenFileInput.value = '';

                return _this.hiddenFileInput.addEventListener("change", function() {
                    var file, files, _i, _len;
                    files = _this.hiddenFileInput.files;
                    if (files.length) {
                        for (_i = 0, _len = files.length; _i < _len; _i++) {
                            file = files[_i];
                            _this.addFile(file);
                        }
                    }
                    _this.emit("addedfiles", files);
                    return setupHiddenFileInput();

                });

            });
kevzlou7979 commented 7 years ago

Thanks for catching this up, might be better to report issue directly to https://github.com/enyo/dropzone/issues - Our core library for FileUploader