From a08020096403b2a97863d071e815d980cebf826a Mon Sep 17 00:00:00 2001 From: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:15:18 +0200 Subject: [PATCH] Only pass context included in `usesContext` from block bindings (#65618) - Only pass context included in `usesContext` Co-authored-by: SantosGuillamot Co-authored-by: gziolo --- .../block-editor/src/components/rich-text/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/index.js b/packages/block-editor/src/components/rich-text/index.js index 9c67476ed0ea63..46ddb2b70a113d 100644 --- a/packages/block-editor/src/components/rich-text/index.js +++ b/packages/block-editor/src/components/rich-text/index.js @@ -179,11 +179,17 @@ export function RichTextWrapper( const blockBindingsSource = getBlockBindingsSource( relatedBinding.source ); + const blockBindingsContext = {}; + if ( blockBindingsSource?.usesContext?.length ) { + for ( const key of blockBindingsSource.usesContext ) { + blockBindingsContext[ key ] = blockContext[ key ]; + } + } const _disableBoundBlock = ! blockBindingsSource?.canUserEditValue?.( { select, - context: blockContext, + context: blockBindingsContext, args: relatedBinding.args, } ); @@ -201,7 +207,7 @@ export function RichTextWrapper( const blockAttributes = getBlockAttributes( clientId ); const fieldsList = blockBindingsSource?.getFieldsList?.( { registry, - context: blockContext, + context: blockBindingsContext, } ); const bindingKey = fieldsList?.[ relatedBinding?.args?.key ]?.label ??