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 withMediaLibraryNotice issue with latest Gutenberg releases #7711

Merged
merged 5 commits into from
Jan 9, 2024

Conversation

thelovekesh
Copy link
Collaborator

@thelovekesh thelovekesh commented Jan 8, 2024

Summary

Update the withMediaLibraryNotice component to extend logic from MediaUpload.buildAndSetFeatureImageFrame.

Fix failing E2E tests due to - WordPress/gutenberg#56921 which updated the class names for Post Preview button in the block editor.

Fixes #7710

Checklist

  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

Copy link
Contributor

github-actions bot commented Jan 8, 2024

Plugin builds for c247702 are ready 🛎️!

Checksums
# Development build checksums
b405fdaefb86252df4656cdc667f8e9bc9830fa0574f953b0c20f3c2e966e5a6 *amp.zip

# Production build checksums
dba089507649a1c576fb69ce1bd1943c85503530855352f4c7b265e4665faa16 *amp.zip

Warning

These builds are for testing purposes only and should not be used in production.

@thelovekesh thelovekesh force-pushed the fix/media-library-issues branch from 124af16 to fd4933a Compare January 8, 2024 09:53
@milindmore22
Copy link
Collaborator

Tested for the following Media blocks

  1. Image
  2. Gallery
  3. Cover Image
  4. Media Tet
  5. Audio
  6. Video

The issue seems resolved.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

Just a couple tweak suggestions. However, I'd love to learn more about how you came up with the code here. I see some of it is forked from underlying code either in Gutenberg or core. Could you add more links to the original code being overridden? Or otherwise if you came up with the code on your own, I'd love to learn how you learned :)

* Create select toolbar.
*
* The only reason for this method is to override the select toolbar view class.
*
Copy link
Member

Choose a reason for hiding this comment

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

@westonruter westonruter added this to the v2.5.2 milestone Jan 8, 2024
@thelovekesh
Copy link
Collaborator Author

However, I'd love to learn more about how you came up with the code here. I see some of it is forked from underlying code either in Gutenberg or core. Could you add more links to the original code being overridden? Or otherwise if you came up with the code on your own, I'd love to learn how you learned :)

I have forked the whole logic from the Gutenberg MediaUpload component and overrode the buildAndSetFeatureImageFrame() which only executes when a user clicks to set the featured image in the block editor.

The only piece modified in forked code is getFeaturedImageMediaFrame():

  • Override createSelectToolbar to hook our notice in the media upload modal.
  • Add suggestedHeight and suggestedWidth in the wp.media.controller.FeaturedImage constructor defaults. So later we can get them from the component state.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

Looks great!

@westonruter westonruter merged commit 99450c0 into develop Jan 9, 2024
31 of 32 checks passed
@westonruter westonruter deleted the fix/media-library-issues branch January 9, 2024 05:03
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breaks image and media blocks with Gutenberg 17.3.0 and 17.4.0
3 participants