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
Do not show "Adding new attribute failed" error message when loading of product screens is interrupted by page unload #38815
Conversation
Test Results SummaryCommit SHA: 03ddbbe
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
72e04fc
to
40b6187
Compare
Hi , @woocommerce/mothra Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to reproduce the issue in Firefox with throttling, as described.
But based on your explanation and by reviewing the code, I think the fix makes a lot of sense, so I'm going to approve it.
d1e6c41
to
0b7cc80
Compare
0b7cc80
to
03ddbbe
Compare
…of product screens is interrupted by page unload (#38815) * Suppress "adding new attribute failed" error message on page unload * Only attempt to add empty attribute if page has attributes list
…of product screens is interrupted by page unload (#38815) * Suppress "adding new attribute failed" error message on page unload * Only attempt to add empty attribute if page has attributes list
Do not show "Adding new attribute failed" error message when loading of product screens is interrupted by page unload (#38815) * Suppress "adding new attribute failed" error message on page unload * Only attempt to add empty attribute if page has attributes list Co-authored-by: Matt Sherman <matt.sherman@automattic.com>
Do not show "Adding new attribute failed" error message when loading of product screens is interrupted by page unload (#38815) * Suppress "adding new attribute failed" error message on page unload * Only attempt to add empty attribute if page has attributes list Co-authored-by: Matt Sherman <matt.sherman@automattic.com>
thank you its been driving me nuts everytiime i click on anything under products on wp-admin |
Still getting this error in 7.9.0 - using google chrome (fully updated). |
Submission Review Guidelines:
Changes proposed in this Pull Request:
Why did this happen
In WooCommerce 7.8 the empty state handling for the attributes tab on the product editor updated (#38126) and then refactored to add an alert when the background request to get the empty attribute form failed (#38354).
Unfortunately, in Firefox (and possibly other browsers), these background requests fail (and the error handling associated with them are executed) when they are canceled due to the entire page being unloaded (Chrome appears to handle this differently, not executing the error handling for these canceled/failed background requests).
To make matters worse, the request to get the empty attribute form was being made when on the product edit/list screen ("All Products":
/wp-admin/edit.php?post_type=product
), when it really only is useful on the product screen ("Add New":/wp-admin/post-new.php?post_type=product
and "Edit":/wp-admin/post.php?post=0000&action=edit
).The page can get unloaded while these background requests are in-progress in normal circumstances when the connection between the browser and the server is slow.
How to reproduce the issue in #38755
A few scenarios where this can be seen:
These can be difficult to reproduce if the timing isn't right. I found that setting my network throttling to "Wi-Fi" in the Network tab of the browser developer tools made it more likely that this occurred.
Also, as mentioned, I have only seen this happen in Firefox.
What is changed in this PR
This PR fixes this error by:
This PR does not stop the
meta-boxes-product.js
andmeta-boxes-product-variation.js
files from being enqueued for theedit-product
screen ("All Products"). While I believe it to be unnecessary in that scenario, those files have been loaded for 5-10 years in that scenario and I want to dig into things a bit further to verify that changing that will introduce no issues that aren't immediately apparent. I will create a follow-up issue to handle this.Also, note that in Firefox there still may be circumstances where messages such as the following still appear in the console:
These messages appeared prior to WooCommerce 7.8. Ideally they would suppressed, but that would be a more involved fix and should be handled separately in the future if desired.
Closes #38755.
How to test the changes in this Pull Request:
With Firefox:
Empty state for attributes tab: