From 267d386a03423c802a856cc34370316787f76be4 Mon Sep 17 00:00:00 2001 From: roykho Date: Wed, 18 Oct 2023 19:25:10 -0700 Subject: [PATCH] Product Gallery: Fix justification not saving correctly --- assets/js/blocks/product-gallery/utils.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/assets/js/blocks/product-gallery/utils.tsx b/assets/js/blocks/product-gallery/utils.tsx index a2e2b5ab307..5fdb4caf798 100644 --- a/assets/js/blocks/product-gallery/utils.tsx +++ b/assets/js/blocks/product-gallery/utils.tsx @@ -170,6 +170,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 ) { @@ -212,6 +216,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' ) &&