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

fix(FileUploaderDropContainer): pass through empty accept attr #4681

Conversation

emyarod
Copy link
Member

@emyarod emyarod commented Nov 14, 2019

Closes #4519

Previously if the user did not supply any file type restrictions, the resulting validated files array would be empty. This PR adds a check for empty accept attribute on drop events to pass through drag and dropped files when the accept attribute is not specified

This PR also adds a code sandbox example application using the dnd uploader

Changelog

New

  • Code Sandbox drag and drop file uploader example

Changed

  • accept prop check in validateFiles method
  • move max-width rule to drop container label to fix a visual bug where the focus outline extended past the drop area

Testing / Reviewing

  • Remove the default accept knob value in storybook
  • ensure the component functions as expected

@emyarod emyarod requested a review from a team as a code owner November 14, 2019 18:05
@ghost ghost requested review from dakahn and joshblack November 14, 2019 18:06
@netlify
Copy link

netlify bot commented Nov 14, 2019

Deploy preview for the-carbon-components ready!

Built with commit d4297c3

https://deploy-preview-4681--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Nov 14, 2019

Deploy preview for carbon-elements ready!

Built with commit d4297c3

https://deploy-preview-4681--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Nov 14, 2019

Deploy preview for carbon-components-react ready!

Built with commit d4297c3

https://deploy-preview-4681--carbon-components-react.netlify.com

@netlify
Copy link

netlify bot commented Nov 14, 2019

Deploy preview for the-carbon-components ready!

Built with commit 19ac3d5

https://deploy-preview-4681--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Nov 14, 2019

Deploy preview for carbon-elements ready!

Built with commit 19ac3d5

https://deploy-preview-4681--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Nov 14, 2019

Deploy preview for carbon-components-react ready!

Built with commit 19ac3d5

https://deploy-preview-4681--carbon-components-react.netlify.com

@Georgegriff
Copy link

bit confused did empty accept ever work? if so when was it changed?
Also when would you predict this fix would be available? trying to decide if i should do the mime type work around for now, which will be tricky since we pretty much allow any files to be uploaded

@emyarod
Copy link
Member Author

emyarod commented Nov 14, 2019

this PR only affects drag and drop behavior. accept by default only affects the operating system's native file picker, and empty accept becomes *.* in the native file picker.

currently the mime types in accept are followed when the user performs a drag and drop upload, but an empty value for accept will cause an error, which is what this PR should address. in this PR empty accept now allows any file to be uploaded via drag and drop just like it would for the native file picker. until this PR is merged in, if you want to be able to accept all mime types for drag and drop uploading specifically, you would have to pass in mime types to accept or modify the component source to match this PR

@Georgegriff
Copy link

@emyarod thanks for the clarity :)

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 - Thanks @emyarod!

Copy link
Contributor

@joshblack joshblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems great, any chance we need to add a test for this or should be good?

@emyarod
Copy link
Member Author

emyarod commented Nov 19, 2019

sure I can look into that

@asudoh asudoh requested a review from a team as a code owner November 19, 2019 22:55
@ghost ghost requested review from abbeyhrt and aledavila November 19, 2019 22:55
@asudoh asudoh merged commit aa46d5d into carbon-design-system:master Nov 19, 2019
@emyarod emyarod deleted the 4519-dnd-file-uploader-accept-attribute branch November 20, 2019 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileUploaderDropContainer - Cannot read property 'uuid' of undefined when dragging a file
5 participants