Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

"Doing it wrong" error triggers after navigating to "Appearance > Widgets" page #10220

Closed
tarhi-saad opened this issue Jul 14, 2023 · 6 comments · Fixed by #10388
Closed

"Doing it wrong" error triggers after navigating to "Appearance > Widgets" page #10220

tarhi-saad opened this issue Jul 14, 2023 · 6 comments · Fixed by #10388
Labels
type: bug The issue/PR concerns a confirmed bug.

Comments

@tarhi-saad
Copy link
Contributor

Describe the bug

GlobalStep discovered this issue as part of critical flow testing.

A WordPress Doing it wrong message appears when the user clicks Appearance > Widgets.

Function wp_enqueue_script() was called incorrectly. "wp-editor" script should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets). (This message was added in version 5.8.0.)

This check was first introduced in this WordPress commit: WordPress/WordPress@846529d. It has the following description:

… in widgets editor

It is common that plugins erroneously have wp-editor or wp-edit-post as a
dependency in a script that is loaded in the new widgets editor. This is a smell
since both @wordpress/editor and @wordpress/edit-post assume the existence
of a global "post" object which the widgets editor does not have.

And here is the original WordPress ticket: https://core.trac.wordpress.org/ticket/53569

The generated Woo Blocks build files build/cart.asset.php and build/checkout.asset.php does indeed include wp-editor as a dependency. Maybe the solution would be to dequeue the wp-editor script on the Widgets page.

To reproduce

Steps to reproduce the behavior:

  1. Use a non Block theme (I tested using the storefront and the Twenty Twenty-one themes)
  2. Install and activate the Query Monitor plugin
  3. Click on the new menu item in the admin toolbar menu to open the overview panel of the Query Monitor plugin
image
  1. Go to Appearance > Widgets
  2. Notice under the Doing it Wrong tab from Query Monitor's overview panel, the error message: Function wp_enqueue_script() was called incorrectly. "wp-editor" script should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets). (This message was added in version 5.8.0.)

Expected behavior

The page should be displayed without any error after navigating to "Woocommerce > Widgets".

Screenshots

image

Environment

WordPress (please complete the following information):

  • WordPress version: 6.2
  • WooCommerce version: 8.0
  • WooCommerce Blocks version: 10.7
  • Site language: English (US)
  • Any other plugins installed: Query Monitor

Desktop (please complete the following information):

  • OS: macOS
  • Browser Chrome
  • Version 114

Additional context

@tarhi-saad tarhi-saad added the type: bug The issue/PR concerns a confirmed bug. label Jul 14, 2023
@tarhi-saad
Copy link
Contributor Author

tarhi-saad commented Jul 17, 2023

Pinging @nefeline because you'll be Porter this week and @gigitux because this bug was introduced in a PR you worked on.

I've done some investigation and found out the source of this bug. In this PR #9386, we introduced the PluginTemplateSettingPanel slot:

import { PluginTemplateSettingPanel } from '@wordpress/edit-site';

Consequently, wp-editor has become a dependency. However, its importation on the Widget page triggers the Doing it wrong error! We must prevent this dependency from being imported on the Widget page.

@gigitux
Copy link
Contributor

gigitux commented Jul 17, 2023

Hey, thanks for the ping! @nefeline, will you work on a fix?

@nefeline
Copy link
Contributor

Hey @tarhi-saad ! Thank you so much for reporting this issue and your investigation 🙏 .

I have a few questions: am I right in my assumption that this issue is not causing any regressions in functionality? Do you believe this is a high priority that must be tackled ASAP by the Porters or can we wait until the next Cooldown?

@tarhi-saad
Copy link
Contributor Author

tarhi-saad commented Jul 20, 2023

Hello @nefeline! I haven't delved deeper to determine whether this error leads to regressions. I'm not fully aware of our stance on Doing it wrong type errors, but I believe that if the solution is straightforward, we could attempt to rectify it without waiting for the cooldown. Please don't hesitate to request the team's input on this matter!

@nefeline
Copy link
Contributor

nefeline commented Jul 20, 2023

Thanks @tarhi-saad. Regarding:

I haven't delved deeper to determine whether this error leads to regressions.

The reason I asked you this is because there's another issue that is breaking the navigation block on WordPress 6.3 that was caused by #9468 , which is a PR that follows up the one you flagged over here as being the cause of this issue: #9386.

I'm still working on a fix for that problem, #10283 , which may or may not have a positive impact on what is reported here, will keep you posted.

cc: @gigitux in case you wanna share your thoughts on this since you worked on both PRs.

@nefeline
Copy link
Contributor

nefeline commented Aug 3, 2023

Hey @tarhi-saad ! Heads up that this problem was solved on #10388 so I'm going ahead and closing this issue. Thanks again for the report and your prompt responses here! 🙌

@nefeline nefeline closed this as completed Aug 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
3 participants