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

directive stops working to select more files than allowed #1388

Closed
dftpnd opened this issue Feb 27, 2016 · 14 comments
Closed

directive stops working to select more files than allowed #1388

dftpnd opened this issue Feb 27, 2016 · 14 comments

Comments

@dftpnd
Copy link

dftpnd commented Feb 27, 2016

ngf-max-files='2' ngf-multiple="true" ngf-keep="true".

  1. select 3 file
  2. uploader not work (You can not select a file 1 or 2)

jsfiddle example

this is a mistake, or i can change the behavior?

@danialfarid
Copy link
Owner

You have ngf-max-files = "2" so if you select 3 files they will be all invalid and will be in ngf-model-invalid.

@danialfarid
Copy link
Owner

I will try to make only the extra files invalid in the next version.

@dftpnd
Copy link
Author

dftpnd commented Mar 1, 2016

You have ngf-max-files = "2" so if you select 3 files they will be all invalid and will be in ngf-model-invalid.

and how can I continue upload?

@dftpnd
Copy link
Author

dftpnd commented Mar 1, 2016

If you set ngf-max-files = "2" and upload 3 files, uploader does not work.

@ray-peters
Copy link

Ran into the same problem.

Steps to recreate:

  1. Create a <ngf-select /> directive with at least the ngf-multiple="true" ngf-max-files="2" and ngf-keep='true' attributes.
  2. Upload more than 2 files on first attempt, triggering validation.
  3. Try to use the <ngf-select /> directive again.

Looks like the ngf-keep attribute is collecting the uploads that are invalid during updateModel() (including uploads that are "invalid" because of maxLength) inside of the prevInvalidFiles array. This then appears to breaks subsequent uploads for the following reasons:

  • The maxLength validation checks against a var allLength, which includes prevInvalidFiles.length in the sum.
  • The removeDuplicates() vets prevInvalidFiles from allNewFiles.

In conclusion, it appears that it would be best to exclude the maxLength invalids from the prevInvalidFiles array. Replacing separateInvalids() with this gist resolves this issue.

@danialfarid
Copy link
Owner

@ray-peters I don't see how the extra directive will be helpful here.
I would go with this #1388 (comment) approach

@ray-peters
Copy link

Hey @danialfarid, thanks for the quick reply.

What should be the expected behavior here? In my opinion, an upload canceled due to reaching the max-files limit should not mark the files as invalid.

From my research, the invalid files are tracked in a way that ngf-keep will not allow you to upload those files again. Either:

  1. The next max-files validation check will return false because max-files is compared to allFiles.length when it seems allValidFiles.length would be more appropriate, and/or
  2. If ngf-keep-distinct === 'true' then removeDuplicates() will vet all prevInvalidFiles from any future attempt to upload.

What do you think?

@danialfarid
Copy link
Owner

Let's say max files is 10 and you selected 12 picture, the last two pictures will be invalid and have error and the form will have validation error max files. Since keep is set adding more files would add them to invalid model until you remove some of the files from the model.

@ray-peters
Copy link

Both ways would work... however I think you might still run into the issues outlined above even if the new uploaded files are partitioned correctly.

@danialfarid
Copy link
Owner

What issues?

@ahmed-abdulmoniem
Copy link

Guys, any fix on that .. this is not enhancement this is a bug because the control stops working totally if I selected more than the max file limit! It will not work until you refresh the page again!

@dftpnd
Copy link
Author

dftpnd commented Mar 10, 2016

+1

1 similar comment
@ahmed-abdulmoniem
Copy link

+1

@danialfarid
Copy link
Owner

Fixed at 12.0.3

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

No branches or pull requests

4 participants