From 25c804ae7cdf06d5230850c08548ac8a1953bd65 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Fri, 15 Mar 2024 18:01:56 +0100 Subject: [PATCH] CYS - Core: fix Product Rating block renders (#45600) * CYS - Core: fix Product Rating block renders * add comment * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions --- .../assembler-hub/block-editor-container.tsx | 14 +++++++++++++- ...-cys-on-core-product-rating-block-not-rendering | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/45600-45593-cys-on-core-product-rating-block-not-rendering diff --git a/plugins/woocommerce-admin/client/customize-store/assembler-hub/block-editor-container.tsx b/plugins/woocommerce-admin/client/customize-store/assembler-hub/block-editor-container.tsx index 31896e0e27b..6914b99416b 100644 --- a/plugins/woocommerce-admin/client/customize-store/assembler-hub/block-editor-container.tsx +++ b/plugins/woocommerce-admin/client/customize-store/assembler-hub/block-editor-container.tsx @@ -16,6 +16,8 @@ import { useQuery } from '@woocommerce/navigation'; // @ts-expect-error No types for this exist yet. import useSiteEditorSettings from '@wordpress/edit-site/build-module/components/block-editor/use-site-editor-settings'; import { useCallback, useContext, useMemo } from '@wordpress/element'; +// @ts-expect-error No types for this exist yet. +import { store as editSiteStore } from '@wordpress/edit-site/build-module/store'; /** * Internal dependencies @@ -78,8 +80,18 @@ export const BlockEditorContainer = () => { [] ); + // This is necessary to avoid this issue: https://github.com/woocommerce/woocommerce/issues/45593 + // Related PR: https://github.com/woocommerce/woocommerce/pull/45600 + const { templateType } = useSelect( ( select ) => { + const { getEditedPostType } = unlock( select( editSiteStore ) ); + + return { + templateType: getEditedPostType(), + }; + }, [] ); + const [ blocks, , onChange ] = useEditorBlocks( - 'wp_template', + templateType, currentTemplate?.id ?? '' ); diff --git a/plugins/woocommerce/changelog/45600-45593-cys-on-core-product-rating-block-not-rendering b/plugins/woocommerce/changelog/45600-45593-cys-on-core-product-rating-block-not-rendering new file mode 100644 index 00000000000..27392a71598 --- /dev/null +++ b/plugins/woocommerce/changelog/45600-45593-cys-on-core-product-rating-block-not-rendering @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +CYS - Core: fix Product Rating block renders \ No newline at end of file