CYS: fix pattern wrapped twice by group blocks (#48712)

* CYS: fix pattern wrapped twice by group blocks

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Luigi Teschio 2024-06-21 15:22:18 +02:00 committed by GitHub
parent 2d14a6fb38
commit 2374240bb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

@ -3,7 +3,7 @@
*/ */
import { useCallback, useMemo, useRef, useState } from '@wordpress/element'; import { useCallback, useMemo, useRef, useState } from '@wordpress/element';
import { useSelect, useDispatch, select } from '@wordpress/data'; import { useSelect, useDispatch, select } from '@wordpress/data';
import { cloneBlock } from '@wordpress/blocks'; import { BlockInstance, cloneBlock } from '@wordpress/blocks';
import { close } from '@wordpress/icons'; import { close } from '@wordpress/icons';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { getNewPath, navigateTo } from '@woocommerce/navigation'; import { getNewPath, navigateTo } from '@woocommerce/navigation';
@ -68,11 +68,13 @@ export const SidebarPatternScreen = ( { category }: { category: string } ) => {
select( blockEditorStore ) select( blockEditorStore )
).__experimentalGetParsedPattern( pattern.name ); ).__experimentalGetParsedPattern( pattern.name );
const clonedParsedPattern = parsedPattern.blocks.map( cloneBlock ); const cloneBlocks = parsedPattern.blocks.map(
( blockInstance: BlockInstance ) => cloneBlock( blockInstance )
);
insertBlocks( clonedParsedPattern, insertableIndex ); insertBlocks( cloneBlocks, insertableIndex );
selectBlock( clonedParsedPattern[ 0 ].clientId, -1 ); selectBlock( cloneBlocks.blocks[ 0 ].clientId, -1 );
}, },
[ insertBlocks, insertableIndex, selectBlock ] [ insertBlocks, insertableIndex, selectBlock ]
); );

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
CYS: fix pattern wrapped twice by group blocks