-
Notifications
You must be signed in to change notification settings - Fork 221
Refactor View Switcher to use Block Attributes #8006
Conversation
The release ZIP for this PR is accessible via:
|
TypeScript Errors ReportFiles with errors: 438
assets/js/base/context/hooks/cart/use-store-cart.ts
assets/js/blocks/cart-checkout-shared/view-switcher/index.tsx assets/js/blocks/cart-checkout-shared/view-switcher/switcher.tsx assets/js/blocks/cart/edit.js assets/js/blocks/checkout/edit.tsx assets/js/blocks/mini-cart/mini-cart-contents/edit.tsx assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/edit.tsx |
Size Change: +1.43 kB (0%) Total Size: 1 MB
ℹ️ View Unchanged
|
The release ZIP for this PR is accessible via:
Script Dependencies ReportThe
This comment was automatically generated by the TypeScript Errors Report
assets/js/base/context/hooks/cart/use-store-cart.ts
assets/js/blocks/cart-checkout-shared/view-switcher/switcher.tsx assets/js/blocks/cart/edit.js assets/js/blocks/checkout/edit.tsx assets/js/blocks/mini-cart/mini-cart-contents/edit.tsx assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/edit.tsx |
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.
Note this also removes `save` which does not exist in Gutenberg.
e2e fails caused by this change should now be resolved. The remaining fails seem unrelated and are being investigated by the fse team. |
Originally we implemented the cart view switcher using Context, with the hope being we could get a change made in Gutenberg so that the Inner Blocks would also show the view switcher with minimal effort (WordPress/gutenberg#35078). This, however, has not been merged, so this is an alternative solution.
The proposed system in this PR removes the state/context and instead uses Block Attributes. Attributes can be accessed and updated by any block in the hierarchy using the Block Client IDs, so we can work our way up the hierarchy looking for
editorViews
, and, if found, render the switcher. The switcher is rendered via a filter/hook, so it applies to all children.Fixes #6985
Testing
User Facing Testing
After testing the cart block, repeat the above tests for the mini cart block. With a block-based theme go here:
WooCommerce Visibility
Changelog