Product Gallery: Fix justification not saving correctly (https://github.com/woocommerce/woocommerce-blocks/pull/11324)

This commit is contained in:
Roy Ho 2023-10-20 05:42:48 -07:00 committed by GitHub
parent d6df0d451b
commit b87aafebe0
1 changed files with 20 additions and 0 deletions

View File

@ -140,6 +140,10 @@ export const moveInnerBlocksToPosition = (
const productGalleryBlock = getBlock( clientId );
if ( productGalleryBlock ) {
const previousLayout = productGalleryBlock.innerBlocks.length
? productGalleryBlock.innerBlocks[ 0 ].attributes.layout
: null;
const thumbnailsBlock = findBlock( {
blocks: [ productGalleryBlock ],
findCondition( block ) {
@ -182,6 +186,22 @@ export const moveInnerBlocksToPosition = (
clientId
);
setGroupBlockLayoutByThumbnailsPosition(
thumbnailsPosition,
productGalleryBlock.innerBlocks[ 0 ].clientId
);
if ( previousLayout ) {
const orientation =
getGroupLayoutAttributes( thumbnailsPosition ).orientation;
updateBlockAttributes(
{
layout: { ...previousLayout, orientation },
},
productGalleryBlock.innerBlocks[ 0 ]
);
}
if (
( ( thumbnailsPosition === 'bottom' ||
thumbnailsPosition === 'right' ) &&