Skip to content

Commit

Permalink
navigation-menu-item: anchor LinkControl at item text
Browse files Browse the repository at this point in the history
  • Loading branch information
retrofox committed Oct 28, 2019
1 parent f8f1290 commit a88b994
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions packages/block-library/src/navigation-menu-item/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,31 @@ function NavigationMenuItemEdit( {
let content;
if ( isSelected ) {
content = (
<TextControl
ref={ plainTextRef }
className="wp-block-navigation-menu-item__field"
value={ label }
onChange={ () => setIsLinkOpen( false ) }
label={ __( 'Navigation Label' ) }
hideLabelFromVision={ true }
/>
<div className="wp-block-navigation-menu-item__field-container">
<TextControl
ref={ plainTextRef }
className="wp-block-navigation-menu-item__field"
value={ label }
onChange={ () => setIsLinkOpen( false ) }
label={ __( 'Navigation Label' ) }
hideLabelFromVision={ true }
/>
{ isLinkOpen &&
<LinkControl
className="wp-block-navigation-menu-item__inline-link-input"
onKeyDown={ handleLinkControlOnKeyDown }
onKeyPress={ ( event ) => event.stopPropagation() }
currentLink={ link }
onLinkChange={ updateLink }
onClose={ () => setIsLinkOpen( false ) }
currentSettings={ linkSettings }
onSettingsChange={ updateLinkSetting }
fetchSearchSuggestions={ fetchSearchSuggestions }
/>
}
</div>
);

} else {
content = <div className="wp-block-navigation-menu-item__container">
{ label }
Expand All @@ -118,19 +134,6 @@ function NavigationMenuItemEdit( {
title={ __( 'Link' ) }
onClick={ () => setIsLinkOpen( ! isLinkOpen ) }
/>
{ isLinkOpen &&
<LinkControl
className="wp-block-navigation-menu-item__inline-link-input"
onKeyDown={ handleLinkControlOnKeyDown }
onKeyPress={ ( event ) => event.stopPropagation() }
currentLink={ link }
onLinkChange={ updateLink }
onClose={ () => setIsLinkOpen( false ) }
currentSettings={ linkSettings }
onSettingsChange={ updateLinkSetting }
fetchSearchSuggestions={ fetchSearchSuggestions }
/>
}
</Toolbar>
</BlockControls>
<InspectorControls>
Expand Down

0 comments on commit a88b994

Please sign in to comment.