Skip to content

Commit

Permalink
Add general override for accessibility label
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiomorales committed Sep 9, 2024
1 parent 5f62c91 commit 0864919
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/block-editor/src/hooks/use-bindings-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function getBindableAttributes( blockName ) {
return BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];
}

export const withBlockBindingSupport = createHigherOrderComponent(
export const editWithBlockBindings = createHigherOrderComponent(
( BlockEdit ) => ( props ) => {
const registry = useRegistry();
const blockContext = useContext( BlockContext );
Expand Down Expand Up @@ -296,9 +296,18 @@ export const withBlockBindingSupport = createHigherOrderComponent(
</>
);
},
'withBlockBindingSupport'
'editWithBlockBindings'
);

function labelWithBlockBindings( settings ) {
return ( attributes, { context } ) => {
if ( attributes?.metadata?.bindings && context === 'accessibility' ) {
return 'Overriding label';
}
return settings.__experimentalLabel?.( attributes, { context } );
};
}

/**
* Filters a registered block's settings to enhance a block's `edit` component
* to upgrade bound attributes.
Expand All @@ -314,7 +323,8 @@ function shimAttributeSource( settings, name ) {

return {
...settings,
edit: withBlockBindingSupport( settings.edit ),
edit: editWithBlockBindings( settings.edit ),
__experimentalLabel: labelWithBlockBindings( settings ),
};
}

Expand Down

0 comments on commit 0864919

Please sign in to comment.