Select the correct inner button for the "Featured Item" button to update its url (https://github.com/woocommerce/woocommerce-blocks/pull/6741)

* Select the correct id/attributes for the button to update its url

* Fix variables case
This commit is contained in:
Alba Rincón 2022-07-26 14:30:18 +02:00 committed by GitHub
parent c7d49bc792
commit e56107f436
1 changed files with 5 additions and 5 deletions

View File

@ -48,14 +48,14 @@ export const withUpdateButtonAttributes =
( item as WP_REST_API_Category )?.link ||
( item as ProductResponseItem )?.permalink;
const Block = useSelect( ( select ) => {
const block = useSelect( ( select ) => {
return select( 'core/block-editor' ).getBlock( clientId );
} );
const InnerButton = Block?.innerBlocks[ 0 ];
const buttonBlockId = InnerButton?.clientId || '';
const innerBlock = block?.innerBlocks[ 0 ]?.innerBlocks[ 0 ];
const buttonBlockId = innerBlock?.clientId || '';
const currentButtonAttributes = useMemo(
() => InnerButton?.attributes || {},
[ InnerButton ]
() => innerBlock?.attributes || {},
[ innerBlock ]
);
const { url } = currentButtonAttributes;