diff --git a/plugins/woocommerce-blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/block.tsx deleted file mode 100644 index 42665c5edeb..00000000000 --- a/plugins/woocommerce-blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/block.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const Block = ( { children }: { children: JSX.Element } ): JSX.Element => { - return <>{ children }; -}; - -export default Block; diff --git a/plugins/woocommerce-blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts b/plugins/woocommerce-blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts index 79aa25254e3..0af519439f1 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts +++ b/plugins/woocommerce-blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts @@ -41,6 +41,7 @@ registerCheckoutBlock( { registerCheckoutBlock( { metadata: miniCartTitleMetadata, + force: false, component: lazy( () => import( diff --git a/plugins/woocommerce-blocks/packages/checkout/blocks-registry/register-checkout-block.ts b/plugins/woocommerce-blocks/packages/checkout/blocks-registry/register-checkout-block.ts index 5c130de1f28..cb1c6150fdf 100644 --- a/plugins/woocommerce-blocks/packages/checkout/blocks-registry/register-checkout-block.ts +++ b/plugins/woocommerce-blocks/packages/checkout/blocks-registry/register-checkout-block.ts @@ -6,7 +6,6 @@ import { registerBlockComponent } from '@woocommerce/blocks-registry'; /** * Internal dependencies */ -import type { CheckoutBlockOptions } from './types'; import { assertBlockName, assertBlockParent, @@ -14,6 +13,7 @@ import { assertBlockComponent, } from './utils'; import { registeredBlocks } from './registered-blocks'; +import type { CheckoutBlockOptions } from './types'; /** * Main API for registering a new checkout block within areas. @@ -34,6 +34,13 @@ export const registerCheckoutBlock = ( component: options.component, } ); + // Infer the `force` value from whether the block is locked or not. But + // allow overriding it on block registration. + const force = + typeof options.force === 'boolean' + ? options.force + : Boolean( options.metadata?.attributes?.lock?.default?.remove ); + /** * Store block metadata for later lookup. */ @@ -41,6 +48,6 @@ export const registerCheckoutBlock = ( blockName: options.metadata.name, metadata: options.metadata, component: options.component, - force: !! options.metadata?.attributes?.lock?.default?.remove, + force, }; }; diff --git a/plugins/woocommerce-blocks/packages/checkout/blocks-registry/types.ts b/plugins/woocommerce-blocks/packages/checkout/blocks-registry/types.ts index 6516621092e..a41038cd0ed 100644 --- a/plugins/woocommerce-blocks/packages/checkout/blocks-registry/types.ts +++ b/plugins/woocommerce-blocks/packages/checkout/blocks-registry/types.ts @@ -46,6 +46,7 @@ export type RegisteredBlocks = Record< string, RegisteredBlock >; export type CheckoutBlockOptions = { metadata: CheckoutBlockOptionsMetadata; + force?: boolean; component: | LazyExoticComponent< React.ComponentType< unknown > > | ( () => JSX.Element | null )