-
Notifications
You must be signed in to change notification settings - Fork 72
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
File Dropzone: Accepts Correct and Rejects Incorrect File Types #2750
base: main
Are you sure you want to change the base?
File Dropzone: Accepts Correct and Rejects Incorrect File Types #2750
Conversation
✅ Deploy Preview for moduswebcomponents ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diTrimInt Thanks for the detailed PR description. I tested your code and found a bug, could you please resolve it?
The accept-types property is mapped to file input type accept
so we should also consider other possible valid values of accept
like images/*
, application/msword. currently it working great if I pass file extensions and break if pass other valid values.
Adding reference link
https://github.com/react-dropzone/attr-accept/blob/66260177829f99c48594dd1fdedaefbb91bdce39/src/index.js#L12
@prashanth-offcl Thank you for letting me know. I will work on adding the logic needed to account for other possible valid values of accept like images/*, application/msword. |
@prashanth-offcl I made the changes to account for other possible valid values of accept like images/*, application/msword. Please let me know if there are anymore needed changes so I can make it before my internship ends 9/20/2024. |
@diTrimInt Looks like the comma separated extension (.doc,.docx) scenario is broken now, and the implemented behavior is consistent with the existing ones. In the existing behavior if there are any errors we don't remove the files directly, we just notify the error to the consumer and let them remove it by calling removeFile method, but the new implementation directly removes the files without notifying the consumer. Can you handle this? |
@prashanth-offcl Thank you for pointing this out. I'll get to work on it. |
@prashanth-offcl Please let me know if there is anything left to correct on this. If I don't have time to make any changes before my internship ends, I can close out this PR, clone the repository on my personal GitHub, and continue to work on it from there. FYI, I would still like to keep contributing after my internship ends from my personal GitHub account. |
return; | ||
} | ||
|
||
if (this.error === 'invalidFileType' && invalidFiles.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diTrimInt if there are no errors then the error variables are reset at the end of this function so we can remove this
} | ||
return acceptedType === fileType; | ||
} else { | ||
return '.' + fileExtension === acceptedType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diTrimInt I'm still able to reproduce the issue with comma separated extensions (.doc,.docx,.jpg,.png). Can we have a separate check for .
like this
Components._.File.Dropzone.-.Default.Storybook.-.Google.Chrome.2024-09-17.15-48-22.mp4
|
||
if (invalidFiles.length > 0) { | ||
this.error = 'invalidFileType'; | ||
this.errorMessageTop = `Some files are not of the accepted types. Please remove the following file(s) to continue: ${invalidFiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check with our UX and get back on how to handle this specific error state with overflowing content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @prashanth-offcl, It's Dion. I will continue the work for my personal Github account (this one). I wanted to follow-up on this comment to see if UX's response for this.
Description
References #2695
Type of change
How Has This Been Tested?
Test Cases
All test cases work for both when dragging or uploading files.
Test Case#1 - Accepting one File Type
Component Attributes For Test
1.mp4
Test Case#2 - Accepting Multiple Types
Component Attributes For Test
2.mp4
Test Case#3 - Accepts Anything
3-REAL.mp4
Test Case#4 - Accepts image/png,.jpeg
3.mp4
Test Case#5 - Accepts image/*
5.mp4
Test Case#6 - Accepts image/png, application/pdf, .jpeg*
6.mp4
Checklist