diff --git a/packages/block-editor/src/components/inserter/index.js b/packages/block-editor/src/components/inserter/index.js index d1613fc1f9d40f..99355b7027136f 100644 --- a/packages/block-editor/src/components/inserter/index.js +++ b/packages/block-editor/src/components/inserter/index.js @@ -31,21 +31,26 @@ const defaultRenderToggle = ( { toggleProps = {}, prioritizePatterns, } ) => { - let label; - if ( hasSingleBlockType ) { + const { + as: Wrapper = Button, + label: labelProp, + onClick, + ...rest + } = toggleProps; + + let label = labelProp; + if ( ! label && hasSingleBlockType ) { label = sprintf( // translators: %s: the name of the block when there is only one _x( 'Add %s', 'directly add the only allowed block' ), blockTitle ); - } else if ( prioritizePatterns ) { + } else if ( ! label && prioritizePatterns ) { label = __( 'Add pattern' ); - } else { + } else if ( ! label ) { label = _x( 'Add block', 'Generic label for block inserter button' ); } - const { onClick, ...rest } = toggleProps; - // Handle both onClick functions from the toggle and the parent component. function handleClick( event ) { if ( onToggle ) { @@ -57,7 +62,7 @@ const defaultRenderToggle = ( { } return ( -