From 798d4dd1d60d33e562168e04fd2d78622123fa10 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Tue, 3 Sep 2024 14:17:05 +0200 Subject: [PATCH 1/3] Add warning with invalid sources --- packages/block-editor/src/hooks/block-bindings.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/hooks/block-bindings.js b/packages/block-editor/src/hooks/block-bindings.js index 3b90ecc1a0c178..e4a7a225ee3e8b 100644 --- a/packages/block-editor/src/hooks/block-bindings.js +++ b/packages/block-editor/src/hooks/block-bindings.js @@ -96,16 +96,20 @@ function BlockBindingsAttribute( { attribute, binding } ) { const { source: sourceName, args } = binding || {}; const sourceProps = unlock( blocksPrivateApis ).getBlockBindingsSource( sourceName ); + const isUndefined = ! sourceProps; return ( { attribute } { !! binding && ( - { args?.key || sourceProps?.label || sourceName } + { ! sourceProps + ? __( 'Invalid source' ) + : args?.key || sourceProps?.label || sourceName } ) } From d50ec5a1d2521a20a7e18670a2911abc6425f171 Mon Sep 17 00:00:00 2001 From: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:18:55 +0200 Subject: [PATCH 2/3] Change variable name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Greg Ziółkowski --- packages/block-editor/src/hooks/block-bindings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/hooks/block-bindings.js b/packages/block-editor/src/hooks/block-bindings.js index e4a7a225ee3e8b..b9ac36843bb9ea 100644 --- a/packages/block-editor/src/hooks/block-bindings.js +++ b/packages/block-editor/src/hooks/block-bindings.js @@ -96,7 +96,7 @@ function BlockBindingsAttribute( { attribute, binding } ) { const { source: sourceName, args } = binding || {}; const sourceProps = unlock( blocksPrivateApis ).getBlockBindingsSource( sourceName ); - const isUndefined = ! sourceProps; + const isSourceInvalid = ! sourceProps; return ( { attribute } From efe38044fc57273f4f09a00fd0d3e6387d1b0c9c Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Tue, 3 Sep 2024 15:21:04 +0200 Subject: [PATCH 3/3] Use `isSourceInvalid` variable --- packages/block-editor/src/hooks/block-bindings.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/hooks/block-bindings.js b/packages/block-editor/src/hooks/block-bindings.js index b9ac36843bb9ea..ea069c15a028fe 100644 --- a/packages/block-editor/src/hooks/block-bindings.js +++ b/packages/block-editor/src/hooks/block-bindings.js @@ -102,12 +102,12 @@ function BlockBindingsAttribute( { attribute, binding } ) { { attribute } { !! binding && ( - { ! sourceProps + { isSourceInvalid ? __( 'Invalid source' ) : args?.key || sourceProps?.label || sourceName }