Make WordPress Core

#59090 closed defect (bug) (duplicate)

Twenty Twenty: 'Uncaught TypeError' when unregistering the squared button block style

Reported by: poena's profile poena Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.3
Component: Bundled Theme Keywords: has-patch
Focuses: Cc:

Description

In WordPress 6.3.0 when the iframe is used in the block editor, there is a JavaScript error:

editor-script-block.js?ver=2.2:7 Uncaught TypeError: wp.domReady is not a function

This error does not happen in earlier versions of WordPress or when the block editor does not use the iframe, for example, when there is a plugin active that uses meta boxes.

editor-script-block.js is used to unregister the squared button block style, which was removed in WordPress version 5.3.

To find the version, I looked at the Gutenberg pull request https://github.com/WordPress/gutenberg/pull/17253
and this list:
https://developer.wordpress.org/block-editor/contributors/versions-in-wordpress/

There is no point in the theme unregistering the non-existing style in WordPress 5.3 or newer, so the file should be loaded conditionally depending on the WordPress version.

Steps to reproduce:
1) Activate Twenty Twenty
2) Open the block editor
3) Open the console in the browser developer tools and confirm if there is a JavaScript error.

Attachments (2)

59090.diff (1017 bytes) - added by poena 14 months ago.
Conditionally load the JavaScript file that unregisters the squared button block style
No-error.png (691.9 KB) - added by mukesh27 14 months ago.

Download all attachments as: .zip

Change History (13)

@poena
14 months ago

Conditionally load the JavaScript file that unregisters the squared button block style

#1 @poena
14 months ago

  • Keywords has-patch needs-testing added
  • Milestone changed from Awaiting Review to 6.3.1

#2 @huzaifaalmesbah
14 months ago

Test Report

I test with 59090.diff

Environment

OS: macOS m1
Web Server: nginx/1.25.0
PHP: 8.1.21
WordPress: 6.3
Browser: Chrome 115.0.5790.98
Theme: Twenty Twenty
Active Plugins: No plugins activated.

Results

it's working with the patch properly. i can't get any error.

Before Applying Patch

https://i.ibb.co/wNGw09Y/After-Applying.png

Version 0, edited 14 months ago by huzaifaalmesbah (next)

#3 @algorithmsunlocks
14 months ago

My Test Report

Tested Version:
WordPress 6.4
Here is the console error screenshot (6.4 has error): https://prnt.sc/Zv9UuJntpndx

Tested Version:
WordPress 6.3
Here is the console screenshot (6.3 has no error): https://prnt.sc/hJrAMdEMyybF

It seems that 6.3 has no error while using the block editor in 6.3.

#4 @mukesh27
14 months ago

  • Keywords reporter-feedback added

Thanks @poena for the ticket and patch.

I can't reproduce the same error in fresh installation. Could you please tell me how i reproduce it? Thanks!

@mukesh27
14 months ago

#5 @poena
14 months ago

Hi,
The steps to reproduce are in the first ticket:

Steps to reproduce:
1) Activate Twenty Twenty
2) Open the block editor
3) Open the console in the browser developer tools and confirm if there is a JavaScript error.

Note that you must deactivate any plugins that use block version 2 or that use meta boxes, otherwise, the iframe will not be used in the block editor.

I did not need to do anything else. I did not need to click anywhere in the UI or add any specific blocks, or view a specific template or similar.
I am using Chrome on macOS.

#6 @poena
14 months ago

Does the sample page use any other blocks than the classic block? Maybe that is it?

#7 @audrasjb
14 months ago

  • Milestone changed from 6.3.1 to 6.3.2

WP 6.3.1 is going to be released in the next few days, so let's move this ticket to 6.3.2 to give it more time to be committed and backported.

#8 @shailu25
14 months ago

Test Report

Patch Tested: https://core.trac.wordpress.org/attachment/ticket/59090/59090.diff

Environment:

WordPress - 6.3.1
OS - Windows
Browser - Chrome
Theme: Twenty Twenty
PHP - 8.0.18
Active Plugin - None

Steps to Reproduce:

1) Activate Twenty Twenty
2) Open the block editor
3) Open the console in the browser developer tools and confirm if there is a JavaScript error.

Expected Results:

After the patch it should work

Actual Results:

✅ Patch is working fine & did not get any error in console

Screenshots:

Before Patch: https://prnt.sc/DvRqK0gcfzbL
After Patch : https://prnt.sc/ycOt7b32MYEi

#9 @costdev
14 months ago

Reproduction Report

Description

This report validates whether the issue can be reproduced.

Environment

  • WordPress: 6.4-alpha-56267-src
  • PHP: 7.4.33
  • Server: Apache/2.4.56 (Ubuntu)
  • Database: mysqli (Server: 5.7.41-0ubuntu0.18.04.1 / Client: 7.4.33)
  • Browser: Chrome 116.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty 2.3
  • MU Plugins: None activated
  • Plugins: None activated

Actual Results

  1. ❌ No error in console. Issue not reproduced.

Notes

  • Also tested on InstaWP and couldn't reproduce the issue.
  • I think we need more investigation to determine how the issue can be reliably reproduced.

#10 @zunaid321
14 months ago

Test Report

This report shows that the issue cannot be reproduced.

Environment

  • OS: Windows 11 (22H2)
  • Web Server: nginx/1.25.1
  • PHP: 7.4.33
  • WordPress: 6.4-alpha-56267-src
  • Browser: Chrome Version 113.0.5672.126 (Official Build) (64-bit)
  • Theme: Twenty Twenty

Results

  • Followed the instructions of @poena
  • ❌ Can't seem to reproduce the error message in the console log.

Screenshots

Error: "editor-script-block.js?ver=2.2:7 Uncaught TypeError: wp.domReady is not a function" does not show up:

https://i.imgur.com/QcLinIm.png

#11 @sabernhardt
14 months ago

  • Keywords needs-testing reporter-feedback removed
  • Milestone 6.3.2 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

As noted on #59086, this is an issue if/when we switch twentytwenty_block_editor_styles() from the enqueue_block_editor_assets action to enqueue_block_assets. The patch on that ticket can be updated to remove the script from the function.

Note: See TracTickets for help on using tickets.