-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Bug]: FileUploader case sensitive extensions #11003
Comments
@joannecl This is odd in that MDN states according to the HTML spec It sounds like you might've found a potential inconsistency with the browser implementation/usage of Does it work if you pass duplicate file extensions as uppercase and also lowercase? I think that would be one workaround the invalid browser behavior. I'm not sure how/if we'd be able to fix this on our end. |
Re-reading the issue, I'm seeing the distinction and was wrong in my previous comment. You've stated the browser behaves properly, allowing selection of .jpg or .JPG, but on selection of a file the validation present in the component is incorrect. I think this is something we could address. |
@joannecl Hello! Thanks for making this issue! Looking into it, browser file look up is case insensitive. From the docs that Taylor linked above, these are what an input with type "file" accepts: "A valid case-insensitive filename extension, starting with a period (".") character. For example: .jpg, .pdf, or .doc." and there is no way for us to change that since it's determined by the browser and there is no configuration available. I think the solution here is to change how you are determining what is |
Thanks @tay1orjones and @abbeyhrt for looking into this one for me! I've just changed accounts for my updated email but I'm the one who created this issue. @abbeyhrt I'm not worried about the browser being case insensitive, I was just mentioning it's inconsistent with how the component works. The way I'm determining Specifically I think it's here:
Where it's using acceptedTypes.has which is case-sensitive to determine if the file has the correct extension or not, then sets the invalid file type property below on line 65 which is inconsistent with the docs as you hav pointed out. I realised I hadn't saved my sandbox properly sorry that wouldn't have helped in the investigation! Thanks again! |
@joanneedwards ah you're totally right, sorry for missing that! Thanks for providing that info! I'll keep looking into this! |
No worries, thanks so much @abbeyhrt ! |
Package
carbon-components-react
Browser
Chrome
Package version
v7.55.1
React version
No response
Description
I noticed the file extensions that are passed into the
accept
property are case sensitive. This may have been by design but using a mac, not sure about windows, the file browser filters files regardless of case. So if I specify .jpg, then upload via clicking through the file browser, all files except .jpg and .JPG are disabled. If I select a .JPG though it will then flag the file as an invalid type. I think the two should be consistent.CodeSandbox example
https://codesandbox.io/s/gifted-surf-8yz5z1?file=/src/FileUploaderExample.js
Steps to reproduce
Code of Conduct
The text was updated successfully, but these errors were encountered: