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

Conversation

@mikejolley
Copy link
Member

Removes usage of the deprecated functions select and dispatch imported from @wordpress/data-controls (deprecated here) and replaces them with controls.select and controls.dispatch from the @wordpress/data package.

Fixes #5339

Questions from the issue:

What version of WordPress is the replacement available?

The switch to @wordpress/data happened in Gutenberg 9.2, which was part of WordPress 5.6, but controls existed before then.

Is the deprecated implementation in Woo Blocks in code that is exposed to users via Woo Core?

Yes, it's part of schema and collections data-stores, used by All Products block.

What version of WordPress does Woo Core still require as minimum support and does that fall in the appropriate range?

The controls export existed in WordPress 5.6 (see here). This is the min supported version of Woo core.

Blocks min support is 5.8. Both are satisfied.

Testing

How to test the changes in this Pull Request:

  1. Smoke test changing quantities of items in the cart
  2. Smoke test All Products block and add to cart buttons within that block
  3. Smoke test All Products block with Filter Blocks

JS tests must also pass. I removed the deprecation assertions from those.

Changelog

Remove deprecated data controls in favour of those from the @wordpress/data package

@rubikuserbot rubikuserbot requested review from a team and senadir and removed request for a team January 17, 2022 14:01
@mikejolley mikejolley self-assigned this Jan 17, 2022
@mikejolley mikejolley added status: needs review type: cooldown Things that are queued for a cooldown period (assists with planning). labels Jan 17, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 17, 2022

Size Change: -14 B (0%)

Total Size: 864 kB

Filename Size Change
build/blocks-checkout.js 17.4 kB -15 B (0%)
build/wc-blocks-data.js 9.83 kB +4 B (0%)
build/wc-blocks-registry.js 2.7 kB +1 B (0%)
build/wc-blocks-shared-hocs.js 1.14 kB -4 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 6.28 kB
build/active-filters.js 6.97 kB
build/all-products-frontend.js 18.6 kB
build/all-products.js 34 kB
build/all-reviews.js 8.03 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/catego--90468e1a.js 223 B
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.64 kB
build/atomic-block-components/add-to-cart-frontend.js 7.01 kB
build/atomic-block-components/add-to-cart.js 7.49 kB
build/atomic-block-components/button--atomic-block-components/category-list--atomic-block-components/imag--f11cdc7a.js 501 B
build/atomic-block-components/button-frontend.js 2.08 kB
build/atomic-block-components/button.js 2.3 kB
build/atomic-block-components/category-list-frontend.js 922 B
build/atomic-block-components/category-list.js 500 B
build/atomic-block-components/image-frontend.js 1.86 kB
build/atomic-block-components/image.js 1.08 kB
build/atomic-block-components/price-frontend.js 1.95 kB
build/atomic-block-components/price.js 1.51 kB
build/atomic-block-components/rating-frontend.js 1.14 kB
build/atomic-block-components/rating.js 717 B
build/atomic-block-components/sale-badge-frontend.js 1.1 kB
build/atomic-block-components/sale-badge.js 683 B
build/atomic-block-components/sku-frontend.js 386 B
build/atomic-block-components/sku.js 386 B
build/atomic-block-components/stock-indicator-frontend.js 1.04 kB
build/atomic-block-components/stock-indicator.js 623 B
build/atomic-block-components/summary-frontend.js 1.34 kB
build/atomic-block-components/summary.js 923 B
build/atomic-block-components/tag-list-frontend.js 923 B
build/atomic-block-components/tag-list.js 498 B
build/atomic-block-components/title-frontend.js 1.31 kB
build/atomic-block-components/title.js 933 B
build/attribute-filter-frontend.js 16.8 kB
build/attribute-filter.js 13.1 kB
build/cart-blocks/accepted-payment-methods-frontend.js 1.16 kB
build/cart-blocks/checkout-button-frontend.js 1.16 kB
build/cart-blocks/empty-cart-frontend.js 346 B
build/cart-blocks/express-payment-frontend.js 5.2 kB
build/cart-blocks/filled-cart-frontend.js 767 B
build/cart-blocks/items-frontend.js 298 B
build/cart-blocks/line-items-frontend.js 5.5 kB
build/cart-blocks/order-summary-frontend.js 8.88 kB
build/cart-blocks/totals-frontend.js 321 B
build/cart-frontend.js 45.3 kB
build/cart.js 43.6 kB
build/checkout-blocks/actions-frontend.js 1.41 kB
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.13 kB
build/checkout-blocks/billing-address-frontend.js 891 B
build/checkout-blocks/contact-information-frontend.js 2.84 kB
build/checkout-blocks/express-payment-frontend.js 5.5 kB
build/checkout-blocks/fields-frontend.js 345 B
build/checkout-blocks/order-note-frontend.js 1.13 kB
build/checkout-blocks/order-summary-frontend.js 11.3 kB
build/checkout-blocks/payment-frontend.js 7.78 kB
build/checkout-blocks/shipping-address-frontend.js 997 B
build/checkout-blocks/shipping-methods-frontend.js 4.73 kB
build/checkout-blocks/terms-frontend.js 1.22 kB
build/checkout-blocks/totals-frontend.js 325 B
build/checkout-frontend.js 47.5 kB
build/checkout.js 44.8 kB
build/featured-category.js 8.63 kB
build/featured-product.js 9.73 kB
build/handpicked-products.js 7.11 kB
build/legacy-template.js 2.19 kB
build/mini-cart-component-frontend.js 16.5 kB
build/mini-cart-contents-block/empty-cart-frontend.js 328 B
build/mini-cart-contents-block/filled-cart-frontend.js 230 B
build/mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js 5.33 kB
build/mini-cart-contents-block/footer-frontend.js 5.67 kB
build/mini-cart-contents-block/items-frontend.js 225 B
build/mini-cart-contents-block/products-table-frontend.js 5.36 kB
build/mini-cart-contents-block/shopping-button-frontend.js 288 B
build/mini-cart-contents-block/title-frontend.js 367 B
build/mini-cart-contents.js 23.6 kB
build/mini-cart-frontend.js 1.72 kB
build/mini-cart.js 6.33 kB
build/price-filter-frontend.js 12.5 kB
build/price-filter.js 8.49 kB
build/price-format.js 1.19 kB
build/product-best-sellers.js 7.39 kB
build/product-categories.js 3.17 kB
build/product-category.js 8.5 kB
build/product-new.js 7.68 kB
build/product-on-sale.js 8 kB
build/product-search.js 2.19 kB
build/product-tag.js 7.83 kB
build/product-top-rated.js 7.92 kB
build/products-by-attribute.js 8.4 kB
build/reviews-by-category.js 11.5 kB
build/reviews-by-product.js 12.6 kB
build/reviews-frontend.js 7.34 kB
build/single-product-frontend.js 22 kB
build/single-product.js 10 kB
build/stock-filter-frontend.js 6.5 kB
build/stock-filter.js 6.58 kB
build/vendors--atomic-block-components/add-to-cart--cart-blocks/order-summary--checkout-blocks/billing-ad--c5eb4dcd-frontend.js 19 kB
build/vendors--atomic-block-components/add-to-cart-frontend.js 7.51 kB
build/vendors--atomic-block-components/price--cart-blocks/line-items--cart-blocks/order-summary--checkout--194c50bf-frontend.js 5.26 kB
build/vendors--cart-blocks/line-items--checkout-blocks/order-summary--mini-cart-contents-block/products-table-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary--checkout-blocks/billing-address--checkout-blocks/order-summary---eb4d2cec-frontend.js 4.74 kB
build/vendors--mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js 7.71 kB
build/wc-blocks-editor-style-rtl.css 4.84 kB
build/wc-blocks-editor-style.css 4.84 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 953 B
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-style-rtl.css 22.2 kB
build/wc-blocks-style.css 22.2 kB
build/wc-blocks-vendors-style-rtl.css 1.28 kB
build/wc-blocks-vendors-style.css 1.28 kB
build/wc-blocks-vendors.js 69.6 kB
build/wc-blocks.js 2.62 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.61 kB

compressed-size-action

@mikejolley mikejolley requested review from a team and alexflorisca and removed request for a team and senadir February 1, 2022 16:55
Copy link
Contributor

@alexflorisca alexflorisca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mikejolley, ran into an issue when testing this

The all products block seems to think there are no products (even though there definitely are)

Screenshot 2022-02-03 at 16 41 56

Filter blocks alongside it also seem to be broken:

Screenshot 2022-02-03 at 16 42 52

I don't know enough about how @wordpress/data works to suggest why this might be but I'm happy to help you figure it out!

The code looks good though and the Cart quantity selector seems to work fine ok and the tests pass 👍

return Promise.resolve( '' );
} );
} );
render( <CartBlock /> );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the render method should go inside the act() function from the react docs

@mikejolley mikejolley force-pushed the fix/deprecated-data-controls branch from b1a5d1e to 58a0383 Compare February 24, 2022 16:46
@mikejolley
Copy link
Member Author

I see the products issue too. I can't figure out why though 🤔 I don't see anything obvious in the diff which would break. I do see const route = yield controls.select is returning blank for some reason.

@mikejolley mikejolley force-pushed the fix/deprecated-data-controls branch from d2b34db to c98c635 Compare March 9, 2022 11:15
@mikejolley
Copy link
Member Author

Found the issue. select does not wait for the resolution. resolveSelect does. See https://github.com/WordPress/gutenberg/blob/trunk/packages/data/src/controls.js#L40-L84

@mikejolley mikejolley requested a review from alexflorisca March 9, 2022 12:09
Copy link
Contributor

@alexflorisca alexflorisca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good spot. I wonder why there's 2 methods, from what I know select ran the resolver automatically if there was one specified and waited for it. Anyway good to go 👍

@github-actions github-actions bot added this to the 7.2.0 milestone Mar 9, 2022
@mikejolley mikejolley modified the milestones: 7.2.0, 7.3.0 Mar 10, 2022
@mikejolley mikejolley merged commit cf2de4d into trunk Mar 10, 2022
@mikejolley mikejolley deleted the fix/deprecated-data-controls branch March 10, 2022 13:22
@tjcafferkey tjcafferkey added skip-changelog PRs that you don't want to appear in the changelog. type: task The issue is an internally driven task (e.g. from another A8c team). labels Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

skip-changelog PRs that you don't want to appear in the changelog. type: cooldown Things that are queued for a cooldown period (assists with planning). type: task The issue is an internally driven task (e.g. from another A8c team).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle select from @wordpress/data-controls deprecation warning

4 participants