#52038 closed defect (bug) (fixed)
Issue in WooCommerce with wp_editor() after update to WP 5.6
Reported by: | rodrigosprimo | Owned by: | azaozz |
---|---|---|---|
Milestone: | 5.6.1 | Priority: | normal |
Severity: | normal | Version: | 5.6.1 |
Component: | General | Keywords: | has-patch needs-testing fixed-major |
Focuses: | Cc: |
Description
I'm opening this ticket because in WooCommerce we are seeing an issue that might be caused by a change in WP 5.6. In wp-admin, if a user opens a product page (products are a custom post type) and then click any link to go to another page, they get a "Changes you made may not be saved" alert even if they haven't made any changes.
This error seems to be triggered by TinyMCE. We are able to reproduce this problem when running WP 5.6, but not when running previous versions of WP. I was not able to determine exactly which WP commit introduced this problem using git bisect
, but that could be because I'm not super familiar with the WP build step.
The problem seems to be related to the call below that WooCommerce makes to wp_editor()
:
I'm inclined to think this is a bug in WP given that the editor is being flagged as dirty and an alert is displayed to the user even when the user didn't change anything. And also given that this is happening when using WP 5.6 but not WP 5.5. That being said, I'm not sure as I couldn't identify the commit that introduced this issue to further investigate it.
Here is the corresponding issue in the WooCommerce GitHub repository: https://github.com/woocommerce/woocommerce/issues/28557
Steps to reproduce the bug:
- Running WP 5.6, install and activate WooCommerce
- In the admin, go to Products > Add new. Alternatively, you can import sample products, go to the list of products, and open the page to edit one of them.
- Without making any changes, click on a different link in the menu. See the alert saying that changes may not be saved.
- Switch to WP 5.5, repeated the steps above and see that there is no alert when leaving the product edit page.
Attachments (3)
Change History (24)
#2
@
4 years ago
Again, I'm suffering from the same symptoms as my own custom posts, including WooCommerce. Other plugins also have symptoms.
#5
@
4 years ago
- Keywords has-patch needs-testing added
Think I got to the bottom of it, at least for beforeunload
. Problem is somewhat related to upstream. The way the (old) autosave code works is by relying on several things/events to happen in the right order when the page is loading and when unloading (I'm surprised it worked well for so many years). Seems after the last TinyMCE update that order changes sometimes.
In 52038.diff:
- Update the
autosave.server.postChanged()
function to specifically look at instances of TinyMCE forcontent
andexcerpt
. - Prefer that function when triggering the AYS on
beforeunload
on the old Edit Post screen (in post.js).
Please test!
Should work correctly with all possible combinations of Visual and Text tabs for both the content and excerpt. It's still possible that the "The backup of this post in your browser..." message may get triggered when reloading the page, but that would require quite larger fix, not suitable for a dot version.
#7
follow-up:
↓ 8
@
4 years ago
Thanks for working on this, @azaozz. I tested and can confirm that your patch fixes the issue that we are seeing on the WooCommerce product pages.
#8
in reply to:
↑ 7
@
4 years ago
Replying to rodrigosprimo:
Thanks for testing!
Should fix all cases when there is a TinyMCE instance on the excerpt
textarea. Going to commit it to trunk hoping it will get some more testing as it touches on showing the "Are you sure" message for the content
editor too.
#9
@
4 years ago
- Owner set to azaozz
- Resolution set to fixed
- Status changed from new to closed
In 49807:
#10
@
4 years ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopen for merging to 5.6.1.
Ideally this would get some more testing with and without TinyMCE in the Excerpt postbox.
#11
@
4 years ago
Thank you for the patch. afterwards,
If you use the custom post type after patching, you will still have symptoms.
Example:
$args = array( 'label' => __( 'Post List', '' ), 'labels' => $labels, 'supports' => array( 'title','editor' ), 'show_in_rest' => true, // Gutenberg Editor ON
This ticket was mentioned in Slack in #forums by timothybjacobs. View the logs.
4 years ago
This ticket was mentioned in Slack in #core by monikarao. View the logs.
4 years ago
This ticket was mentioned in Slack in #core by monikarao. View the logs.
4 years ago
#15
@
4 years ago
I also tested this patch and can confirm that it fixes the issue. I am no longer seeing the "changes may not be saved" alert.
@ifnoob - can you please provide steps to reproduce since you are still seeing this issue on a different use case?
#18
@
4 years ago
I now got this weird message on Pages and CPTs after updating wp to 5.6.1
I checked posts and products and no pop up message is shown.
I think this bug is more widespread than just Woocommerce. I've also seen it in CMB2 and in the Advanced Post Excerpt plugin on a clean install of WordPress 5.6.
I have seen that if I'm on a post type that has the Block Editor enabled,
wp_editor
does not seem to have the same problem.