Skip to content

Commit

Permalink
Block Bindings: Remove key fallback in bindings get values and rely o…
Browse files Browse the repository at this point in the history
…n source label (#65517)

* Always fall back to source label

* Adapt e2e tests

Co-authored-by: SantosGuillamot <[email protected]>
Co-authored-by: gziolo <[email protected]>
  • Loading branch information
3 people authored and kevin940726 committed Sep 23, 2024
1 parent 4c9fdd1 commit 814d35c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
5 changes: 2 additions & 3 deletions packages/block-editor/src/hooks/use-bindings-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( {
Expand Down
26 changes: 1 addition & 25 deletions test/e2e/specs/editor/various/block-bindings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( {
Expand All @@ -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' );
} );

Expand Down

0 comments on commit 814d35c

Please sign in to comment.