Skip to content

Commit

Permalink
Emit empty change record when file input value is cleared
Browse files Browse the repository at this point in the history
Chrome clears the file input value when the file selection dialog is cleared.
If a file was already chosen this creates a change, but the data array
provided to `onChange` wasn't accounting for this so a dummy file object
gets passed instead of an array.
  • Loading branch information
deanlandolt committed Jul 10, 2014
1 parent aab9f16 commit 5c5dab6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions form/FileUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,11 +1021,18 @@ return declare("dojox.form.FileUploader", [Widget, TemplatedMixin, Contained], {
}));
this._cons.push(connect.connect(this._fileInput, "change", this, function(){
this._checkHtmlCancel("change");
this._change([{
name: this._fileInput.value,
type: "",
size: 0
}]);
var name = this._fileInput.value;
if(name){
this._change([{
name: name,
type: "",
size: 0
}]);
}else{
// If input's value is empty it's been cleared so we emit an empty change record
this._change([]);
}

}));
if(this.tabIndex>=0){
domAttr.set(this.domNode, "tabIndex", this.tabIndex);
Expand Down

0 comments on commit 5c5dab6

Please sign in to comment.