Return a class component from the editor.MediaUpload filter for compatibility with other plugins #247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses this issue opened on the AMP plugin repo: ampproject/amp-wp#5534 Note that this issue completely breaks the block editor when both plugins are active, making the two plugins incompatible.
The AMP plugin uses the
editor.MediaUploadfilter expecting to filter a class component. This is because the original component from Gutenberg core is a class component:https://github.com/WordPress/gutenberg/blob/95188199c8b8045322d7f75a2666d47ea6504ad2/packages/media-utils/src/components/media-upload/index.js#L227
The Cloudinary plugin, however, uses the same filter to return a function component. When Cloudinary's callback runs first, the subsequent callback is no longer able to extend the component as expected, causing an error that breaks the editor.
For reference, here's where the AMP plugin extends the original component, expecting a class: https://github.com/ampproject/amp-wp/blob/6ceca505b3be3a75f460a641f9bfb208c7bf67e6/assets/src/block-editor/components/with-media-library-notice.js#L32