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

Only check MediaPlaceholder allowedTypes array length if prop exists #11694

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/editor/src/components/media-placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class MediaPlaceholder extends Component {
onHTMLDrop = noop,
multiple = false,
notices,
allowedTypes,
allowedTypes = [],
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that the prop is also used in onlyAllowsImages and onlyAllowsImages methods, should we add the default values there too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into that earlier, and I don't think changes are necessary in either of those cases. On onlyAllowsImages and onFilesUpload both, the existing logic should handle both [] and null/false/undefined/etc. (onlyAllowsImages has the checks in the media placeholder component, while onFilesUpload passes the prop value through to be checke within the mediaUpload method)

} = this.props;

const {
Expand Down
17 changes: 17 additions & 0 deletions packages/editor/src/components/media-placeholder/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* External dependencies
*/
import { mount } from 'enzyme';

/**
* Internal dependencies
*/
import MediaPlaceholder from '../';

describe( 'MediaPlaceholder', () => {
it( 'renders successfully when allowedTypes property is not specified', () => {
expect( () => mount(
<MediaPlaceholder />
) ).not.toThrow();
} );
} );