Style Book: Fix Featured Product and Featured Category Blocks preview (https://github.com/woocommerce/woocommerce-blocks/pull/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 <thomas.roberts@automattic.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
This commit is contained in:
Luigi Teschio 2023-01-27 14:19:40 +01:00 committed by GitHub
parent 5fc14d42a0
commit c02726e1c1
4 changed files with 6 additions and 1 deletions

View File

@ -80,6 +80,7 @@
"default": 500
},
"linkText": {
"default": "Shop now",
"type": "string"
},
"categoryId": {

View File

@ -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;

View File

@ -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;

View File

@ -116,7 +116,7 @@ export function register(
...DEFAULT_SETTINGS,
example: {
...DEFAULT_EXAMPLE,
example,
...example,
},
/**
* Renders and manages the block.