-
Notifications
You must be signed in to change notification settings - Fork 96
Description
Great addon!
Right now, using the supplied file-field component you cannot select the same file twice.
In the sense that (assuming you have the code to support this)
- User selects a file
- Through the implementation, the user cancels that upload
- User remembers that in fact, that was the correct thing to do
- User try's to upload that same file again
Expected: The filesDidChange action to be triggered with the file selected.
Actual: The filesDidChange action is not fired because the change event is not fired.
This is actually the default behavior of input type file. The inputs value attribute still holds the previous file and does not think it has changed, and thus, no change event.
If ember-uploader wants the default behavior to clear the input value after filesDidChange event then it would be as simple as adding a hook to clear that value.
If ember-uploader does not want this behavior, let this issue be found in google searches henceforth.
In our implementation, to fix this, we added a this.$('input').val(null) after the change handler which resets the inputs value attribute:
import EmberUploader from 'ember-uploader';
export default EmberUploader.FileField.extend({
onFilesDidChange: null,
filesDidChange(files) {
this.sendAction('onFilesDidChange', files);
this.$().val(null);
},
});Relates to: #134