-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Inserter on navigation menu sidebar.
- Loading branch information
1 parent
55a71ae
commit a433b4f
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
packages/edit-site/src/components/navigation-inspector/appender.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Inserter } from '@wordpress/block-editor'; | ||
import { Button } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { plus } from '@wordpress/icons'; | ||
|
||
export default function Appender( { clientId } ) { | ||
return ( | ||
<div className="edit-site-navigation-inspector__appender"> | ||
<Inserter | ||
rootClientId={ clientId } | ||
position="bottom right" | ||
isAppender={ true } | ||
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 } | ||
onClick={ handleClick } | ||
className="block-editor-inserter__toggle" | ||
aria-haspopup={ | ||
! hasSingleBlockType ? 'true' : false | ||
} | ||
aria-expanded={ | ||
! hasSingleBlockType ? isOpen : false | ||
} | ||
disabled={ disabled } | ||
{ ...rest } | ||
> | ||
{ __( 'Add menu item' ) } | ||
</Button> | ||
); | ||
} } | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters