Skip to content

Commit

Permalink
Include Add menu item text on off canvas editor inserter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Jan 6, 2023
1 parent 0b6a6be commit aac377c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
41 changes: 41 additions & 0 deletions packages/block-editor/src/components/off-canvas-editor/appender.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*/
import { useSelect } from '@wordpress/data';
import { forwardRef } from '@wordpress/element';
import { plus } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -41,6 +45,43 @@ export const Appender = forwardRef( ( props, ref ) => {
selectBlockOnInsert={ false }
shouldDirectInsert={ false }
__experimentalIsQuick
renderToggle={ ( {
onToggle,
disabled,
isOpen,
hasSingleBlockType,
toggleProps = {},
} ) => {
const { onClick, ...rest } = toggleProps;
// Handle both onClick functions from the toggle and the parent component.
function handleClick( event ) {
if ( onToggle ) {
onToggle( event );
}
if ( onClick ) {
onClick( event );
}
}
return (
<Button
icon={ plus }
label={ __( 'Add menu item' ) }
tooltipPosition="bottom"
onClick={ handleClick }
className="block-editor-inserter__toggle"
aria-haspopup={
! hasSingleBlockType ? 'true' : false
}
aria-expanded={
! hasSingleBlockType ? isOpen : false
}
disabled={ disabled }
{ ...rest }
>
{ __( 'Add menu item' ) }
</Button>
);
} }
{ ...props }
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
.offcanvas-editor__appender .block-editor-inserter__toggle {
background-color: #1e1e1e;
color: #fff;
margin: $grid-unit-10 0 0 24px;
border-radius: 2px;
height: 24px;
min-width: 24px;
padding: 0;

&:hover,
&:focus {
background: var(--wp-admin-theme-color);
color: #fff;
}
padding: 6px 6px 6px 0;
}

.offcanvas-editor-list-view-tree-wrapper {
Expand Down

0 comments on commit aac377c

Please sign in to comment.