Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot select same file twice with file-field component #145

Open
Duder-onomy opened this issue Feb 6, 2017 · 1 comment
Open

Cannot select same file twice with file-field component #145

Duder-onomy opened this issue Feb 6, 2017 · 1 comment

Comments

@Duder-onomy
Copy link

Duder-onomy commented Feb 6, 2017

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

@digitaltoad
Copy link
Member

The problem with this is that just clearing the value, depending on the browser, doesn't always work. You could simulate what you are referring to by rendering a new file input after selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants