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

Breaks image and media blocks with Gutenberg 17.3.0 and 17.4.0 #7710

Closed
cagrimmett opened this issue Jan 4, 2024 · 3 comments · Fixed by #7711
Closed

Breaks image and media blocks with Gutenberg 17.3.0 and 17.4.0 #7710

cagrimmett opened this issue Jan 4, 2024 · 3 comments · Fixed by #7711
Assignees
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes. P0 High priority
Milestone

Comments

@cagrimmett
Copy link

cagrimmett commented Jan 4, 2024

Bug Description

With Gutenberg 17.3.0 and above activated alongside AMP, the Image, Gallery, and Media & Text blocks do not work in the editor. They show "This block has encountered an error and cannot be previewed."

Related console error:

react-dom.min.js?ver=18:1 TypeError: Cannot read properties of undefined (reading 'off')
    at new <anonymous> (amp-block-editor.js?ver=58945a960ba3c840b940:3:522)
    at ut (react-dom.min.js?ver=18:1:39330)
    at br (react-dom.min.js?ver=18:1:56687)
    at $s (react-dom.min.js?ver=18:1:121525)
    at Sl (react-dom.min.js?ver=18:1:88649)
    at kl (react-dom.min.js?ver=18:1:88577)
    at bl (react-dom.min.js?ver=18:1:88440)
    at sl (react-dom.min.js?ver=18:1:85264)
    at dl (react-dom.min.js?ver=18:1:85651)
    at Nn (react-dom.min.js?ver=18:1:32464)

Relevant block from amp-block-editor.js:

constructor(...e) {
      super(...e),
      "editor-post-featured-image__media-modal" === this.props.modalClass ? (this.initFeaturedImage = this.initFeaturedImage.bind(this),
      this.initFeaturedImage()) : (this.frame.off("open", this.onOpen),
      this.frame.on("open", super.onOpen.bind(this)))
  }

Expected Behaviour

The core blocks should work as expected

Screenshots

CleanShot 2024-01-04 at 10 38 17@2x

PHP Version

8.2

Plugin Version

2.5.1

AMP plugin template mode

Standard

WordPress Version

6.4.2

Site Health

No response

Gutenberg Version

17.3.0 and above

OS(s) Affected

No response

Browser(s) Affected

No response

Device(s) Affected

No response

Acceptance Criteria

No response

Implementation Brief

No response

QA Testing Instructions

No response

Demo

No response

Changelog Entry

No response

@westonruter
Copy link
Member

Related source code:

constructor(...args) {
super(...args);
// @todo This should be a different event.
// This class should only be present in the MediaUpload for the Featured Image.
if (
'editor-post-featured-image__media-modal' ===
this.props.modalClass
) {
this.initFeaturedImage = this.initFeaturedImage.bind(this);
this.initFeaturedImage();
} else {
// Restore the original`onOpen` callback as it will be overridden by the parent class.
this.frame.off('open', this.onOpen);
this.frame.on('open', super.onOpen.bind(this));
}
}

@westonruter
Copy link
Member

@thelovekesh If this turns out to be a challenge to fix for compatibility with the latest Gutenberg, I think we should just eliminate the with-media-library-notice component entirely. I don't think the notice is particularly useful for users.

@pavanpatil1
Copy link

Verified the fix and it is working fine with and without the Gutenberg, as well as with earlier versions of WordPress.

  • With WordPress 5.3 it is not showing the feature image notice as MediaUpload component is not supported.
  • With WordPress 5.9 it is showing the correct notice regarding to the feature image with and without Gutenberg plugin.
  • With the Latest WordPress the notice is visible and other block editor functionality is also working fine.

Also, It is not breaking any other functionality in the Block editor.

@thelovekesh thelovekesh self-assigned this Jan 9, 2024
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Jan 10, 2024
@github-project-automation github-project-automation bot moved this to Done in Ongoing Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes. P0 High priority
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants