From 79c945905d01b840f08d0b7518615f7e4a6ba991 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Wed, 17 May 2023 15:25:02 +0200 Subject: [PATCH] Fix undo button (#9478) * fix undo button * fix label --- assets/js/blocks/classic-template/index.tsx | 13 ++++++------- assets/js/blocks/classic-template/single-product.ts | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/assets/js/blocks/classic-template/index.tsx b/assets/js/blocks/classic-template/index.tsx index 9271db20e14..932aa12bd15 100644 --- a/assets/js/blocks/classic-template/index.tsx +++ b/assets/js/blocks/classic-template/index.tsx @@ -22,7 +22,7 @@ import { Button, Placeholder, Popover } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { box, Icon } from '@wordpress/icons'; import { useDispatch, subscribe, useSelect, select } from '@wordpress/data'; -import { useEffect, useMemo, useState } from '@wordpress/element'; +import { useEffect, useState } from '@wordpress/element'; import { store as noticesStore } from '@wordpress/notices'; import { useEntityRecord } from '@wordpress/core-data'; @@ -100,12 +100,6 @@ const Edit = ( { const { createInfoNotice } = useDispatch( noticesStore ); - const blocks = getBlocks(); - - const clientIds = useMemo( () => { - pickBlockClientIds( blocks ); - }, [ blocks ] ); - const blockProps = useBlockProps(); const templateDetails = getTemplateDetailsBySlug( attributes.template, @@ -177,6 +171,11 @@ const Edit = ( { 'woo-gutenberg-products-block' ), onClick: () => { + const clientIds = + pickBlockClientIds( + getBlocks() + ); + replaceBlocks( clientIds, createBlock( diff --git a/assets/js/blocks/classic-template/single-product.ts b/assets/js/blocks/classic-template/single-product.ts index 1e907e7e3b8..1dca28bffa3 100644 --- a/assets/js/blocks/classic-template/single-product.ts +++ b/assets/js/blocks/classic-template/single-product.ts @@ -63,7 +63,7 @@ const getDescriptionAllowingConversion = ( templateTitle: string ) => sprintf( /* translators: %s is the template title */ __( - 'Transform this template into multiple blocks so you can add, remove, reorder, and customize your %s.', + 'Transform this template into multiple blocks so you can add, remove, reorder, and customize your %s template.', 'woo-gutenberg-products-block' ), templateTitle