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

Commit

Permalink
Style Book: Fix Featured Product and Featured Category Blocks preview (
Browse files Browse the repository at this point in the history
…#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 <[email protected]>
Co-authored-by: Paulo Arromba <[email protected]>
  • Loading branch information
3 people authored Jan 27, 2023
1 parent 2976e87 commit 1863ca7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"default": 500
},
"linkText": {
"default": "Shop now",
"type": "string"
},
"categoryId": {
Expand Down
2 changes: 2 additions & 0 deletions assets/js/blocks/featured-items/featured-category/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ type ExampleBlock = Block[ 'example' ] & {
attributes: {
categoryId: 'preview' | number;
previewCategory: typeof previewCategories[ number ];
editMode: false;
};
};

export const example: ExampleBlock = {
attributes: {
categoryId: 'preview',
previewCategory: previewCategories[ 0 ],
editMode: false,
},
} as const;
2 changes: 2 additions & 0 deletions assets/js/blocks/featured-items/featured-product/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ type ExampleBlock = Block[ 'example' ] & {
attributes: {
productId: 'preview' | number;
previewProduct: typeof previewProducts[ number ];
editMode: false;
};
};

export const example: ExampleBlock = {
attributes: {
productId: 'preview',
previewProduct: previewProducts[ 0 ],
editMode: false,
},
} as const;
2 changes: 1 addition & 1 deletion assets/js/blocks/featured-items/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function register(
...DEFAULT_SETTINGS,
example: {
...DEFAULT_EXAMPLE,
example,
...example,
},
/**
* Renders and manages the block.
Expand Down

0 comments on commit 1863ca7

Please sign in to comment.