From f54d88ca25f6c5321e9284da88dad21090493e11 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Wed, 12 Jun 2024 14:55:09 +0800 Subject: [PATCH] Only skip normal attribute updates for pattern overrides --- .../src/hooks/use-bindings-attributes.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/hooks/use-bindings-attributes.js b/packages/block-editor/src/hooks/use-bindings-attributes.js index 32cdd15f19e7dc..7bd5df05d31eb4 100644 --- a/packages/block-editor/src/hooks/use-bindings-attributes.js +++ b/packages/block-editor/src/hooks/use-bindings-attributes.js @@ -97,8 +97,9 @@ export const withBlockBindingSupport = createHigherOrderComponent( unlock( select( blocksStore ) ).getAllBlockBindingsSources() ); const { name, clientId, context } = props; - const hasDefaultBinding = - props.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]; + const hasPatternOverridesDefaultBinding = + props.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ] + ?.source === 'core/pattern-overrides'; const bindings = useMemo( () => replacePatternOverrideDefaultBindings( @@ -215,8 +216,11 @@ export const withBlockBindingSupport = createHigherOrderComponent( } } + // Only apply normal attribute updates to blocks + // that have partial bindings. Currently this is + // only skipped for pattern overrides sources. if ( - ! hasDefaultBinding && + ! hasPatternOverridesDefaultBinding && Object.keys( keptAttributes ).length ) { setAttributes( keptAttributes ); @@ -231,7 +235,7 @@ export const withBlockBindingSupport = createHigherOrderComponent( context, setAttributes, sources, - hasDefaultBinding, + hasPatternOverridesDefaultBinding, ] );