From b1b768c7db44da6ae21533c7cd5c015733a89ddf Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Fri, 24 May 2024 10:44:01 +0200 Subject: [PATCH] Change parent context logic --- packages/block-editor/src/store/selectors.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 5e11cd34acf9d..60af4169e2c62 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -2516,9 +2516,16 @@ export function getBlockContext( state, clientId ) { // TODO: Review if it's necessary to get the context from the parent blocks. getBlockParents( state, clientId ).forEach( ( parent ) => { const block = getBlock( state, parent ); - const blockType = getBlockType( state, block.name ); + const blockType = getBlockType( block.name ); if ( blockType?.providesContext ) { - blockContext = { ...blockContext, ...blockType?.providesContext }; + Object.keys( blockType.providesContext ).forEach( + ( attributeName ) => { + blockContext = { + ...blockContext, + [ attributeName ]: block.attributes[ attributeName ], + }; + } + ); } } ); return blockContext;