From cb4bbea0c7ee2478863429200c3fa7ac6852e19a Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Fri, 20 Sep 2024 12:25:31 +0200 Subject: [PATCH 1/2] Always fall back to source label --- packages/block-editor/src/hooks/use-bindings-attributes.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/hooks/use-bindings-attributes.js b/packages/block-editor/src/hooks/use-bindings-attributes.js index e1ebf5fda6b8ee..ac045004cc654b 100644 --- a/packages/block-editor/src/hooks/use-bindings-attributes.js +++ b/packages/block-editor/src/hooks/use-bindings-attributes.js @@ -162,9 +162,8 @@ export const withBlockBindingSupport = createHigherOrderComponent( let values = {}; if ( ! source.getValues ) { Object.keys( bindings ).forEach( ( attr ) => { - // Default to the `key` or the source label when `getValues` doesn't exist - values[ attr ] = - bindings[ attr ].args?.key || source.label; + // Default to the the source label when `getValues` doesn't exist. + values[ attr ] = source.label; } ); } else { values = source.getValues( { From 88947681fda45d1c7ed91ce0fb9a2eeacbb1a266 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Fri, 20 Sep 2024 12:27:44 +0200 Subject: [PATCH 2/2] Adapt e2e tests --- .../editor/various/block-bindings.spec.js | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/test/e2e/specs/editor/various/block-bindings.spec.js b/test/e2e/specs/editor/various/block-bindings.spec.js index c556c469698ebd..90a5d2b1da9f10 100644 --- a/test/e2e/specs/editor/various/block-bindings.spec.js +++ b/test/e2e/specs/editor/various/block-bindings.spec.js @@ -66,7 +66,7 @@ test.describe( 'Block bindings', () => { ); } ); - test( 'should show the key of the custom field in server sources with key', async ( { + test( 'should always show the source label in server-only sources', async ( { editor, } ) => { await editor.insertBlock( { @@ -86,30 +86,6 @@ test.describe( 'Block bindings', () => { const paragraphBlock = editor.canvas.getByRole( 'document', { name: 'Block: Paragraph', } ); - await expect( paragraphBlock ).toHaveText( - 'text_custom_field' - ); - } ); - - test( 'should show the source label in server sources without key', async ( { - editor, - } ) => { - await editor.insertBlock( { - name: 'core/paragraph', - attributes: { - content: 'paragraph default content', - metadata: { - bindings: { - content: { - source: 'core/server-source', - }, - }, - }, - }, - } ); - const paragraphBlock = editor.canvas.getByRole( 'document', { - name: 'Block: Paragraph', - } ); await expect( paragraphBlock ).toHaveText( 'Server Source' ); } );