Product SKU: fix preview on the Single Product Block (https://github.com/woocommerce/woocommerce-blocks/pull/8805)

This commit is contained in:
Luigi Teschio 2023-04-13 19:10:41 +02:00 committed by GitHub
parent aaeb6af909
commit c3f585ef55
1 changed files with 9 additions and 1 deletions

View File

@ -3,6 +3,7 @@
*/
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import { InnerBlockTemplate } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
/**
* Internal dependencies
@ -10,6 +11,13 @@ import { InnerBlockTemplate } from '@wordpress/blocks';
import './editor.scss';
const Edit = () => {
const isDescendentOfSingleProductTemplate = useSelect( ( select ) => {
const store = select( 'core/edit-site' );
const postId = store?.getEditedPostId< string | undefined >();
return postId?.includes( '//single-product' );
}, [] );
const TEMPLATE: InnerBlockTemplate[] = [
[
'core/group',
@ -18,7 +26,7 @@ const Edit = () => {
[
'woocommerce/product-sku',
{
isDescendentOfSingleProductTemplate: true,
isDescendentOfSingleProductTemplate,
},
],
[