From 1863ca7797df0c5fb53690392abd88dff1402d97 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Fri, 27 Jan 2023 14:19:40 +0100 Subject: [PATCH] Style Book: Fix Featured Product and Featured Category Blocks preview (#8313) * Subscribe only to changes on core/block-editor * Improve performance of useForcedLayou This is because by the time we reach this line, innerBlocks will be an empty array (or we wouldn't make it this far) and if nextBlocks contains ANY items it will, by definition be unequal, so a length check is simpler and more performant. Also we can remove the dependence on yet another lodash function by doing it this way. * Check if templates synced before doing it again in useForcedLayout * Style Book: Fix Featured Product and Featured Category Blocks Co-authored-by: Thomas Roberts Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> --- assets/js/blocks/featured-items/featured-category/block.json | 1 + assets/js/blocks/featured-items/featured-category/example.ts | 2 ++ assets/js/blocks/featured-items/featured-product/example.ts | 2 ++ assets/js/blocks/featured-items/register.tsx | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/js/blocks/featured-items/featured-category/block.json b/assets/js/blocks/featured-items/featured-category/block.json index 1a965571649..8f2dbb33467 100644 --- a/assets/js/blocks/featured-items/featured-category/block.json +++ b/assets/js/blocks/featured-items/featured-category/block.json @@ -80,6 +80,7 @@ "default": 500 }, "linkText": { + "default": "Shop now", "type": "string" }, "categoryId": { diff --git a/assets/js/blocks/featured-items/featured-category/example.ts b/assets/js/blocks/featured-items/featured-category/example.ts index 58cbc6c5777..be5cb5f0046 100644 --- a/assets/js/blocks/featured-items/featured-category/example.ts +++ b/assets/js/blocks/featured-items/featured-category/example.ts @@ -8,6 +8,7 @@ type ExampleBlock = Block[ 'example' ] & { attributes: { categoryId: 'preview' | number; previewCategory: typeof previewCategories[ number ]; + editMode: false; }; }; @@ -15,5 +16,6 @@ export const example: ExampleBlock = { attributes: { categoryId: 'preview', previewCategory: previewCategories[ 0 ], + editMode: false, }, } as const; diff --git a/assets/js/blocks/featured-items/featured-product/example.ts b/assets/js/blocks/featured-items/featured-product/example.ts index daedefe31ba..f0c23a7e6c5 100644 --- a/assets/js/blocks/featured-items/featured-product/example.ts +++ b/assets/js/blocks/featured-items/featured-product/example.ts @@ -8,6 +8,7 @@ type ExampleBlock = Block[ 'example' ] & { attributes: { productId: 'preview' | number; previewProduct: typeof previewProducts[ number ]; + editMode: false; }; }; @@ -15,5 +16,6 @@ export const example: ExampleBlock = { attributes: { productId: 'preview', previewProduct: previewProducts[ 0 ], + editMode: false, }, } as const; diff --git a/assets/js/blocks/featured-items/register.tsx b/assets/js/blocks/featured-items/register.tsx index 0593f73b8b8..912cc26e38b 100644 --- a/assets/js/blocks/featured-items/register.tsx +++ b/assets/js/blocks/featured-items/register.tsx @@ -116,7 +116,7 @@ export function register( ...DEFAULT_SETTINGS, example: { ...DEFAULT_EXAMPLE, - example, + ...example, }, /** * Renders and manages the block.