Skip to content

Commit

Permalink
Add attribute so Nav Editor can hide justify
Browse files Browse the repository at this point in the history
- Adds an additional attribute to showJustifyControls to nvaigation
block so the Nav Editor screen can hide the controls, since that screen
is intended to create/edit nav menus and not format/style.

- Add attribute to Nav Editor to set as false

- Use 'showJustifyControls' since the positive is easier to reason and
there is already a 'showSubMenuIcon' attribute that also defaults to
true
  • Loading branch information
mkaz committed Apr 5, 2021
1 parent 6b6b9d7 commit 9ebbbab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
5 changes: 5 additions & 0 deletions packages/block-library/src/navigation/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"showSubmenuIcon": {
"type": "boolean",
"default": true
},
"showJustifyControls": {
"type": "boolean",
"default": true
}
},
"providesContext": {
Expand All @@ -40,6 +44,7 @@
"fontSize": "fontSize",
"customFontSize": "customFontSize",
"showSubmenuIcon": "showSubmenuIcon",
"showJustifyControls": "showJustifyControls",
"style": "style",
"orientation": "orientation"
},
Expand Down
24 changes: 13 additions & 11 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,19 @@ function Navigation( {
return (
<>
<BlockControls>
<JustifyToolbar
value={ attributes.itemsJustification }
allowedControls={ justifyAllowedControls }
onChange={ ( value ) =>
setAttributes( { itemsJustification: value } )
}
popoverProps={ {
position: 'bottom right',
isAlternate: true,
} }
/>
{ attributes.showJustifyControls && (
<JustifyToolbar
value={ attributes.itemsJustification }
allowedControls={ justifyAllowedControls }
onChange={ ( value ) =>
setAttributes( { itemsJustification: value } )
}
popoverProps={ {
position: 'bottom right',
isAlternate: true,
} }
/>
) }
<ToolbarGroup>{ navigatorToolbarButton }</ToolbarGroup>
</BlockControls>
{ navigatorModal }
Expand Down
1 change: 1 addition & 0 deletions packages/edit-navigation/src/store/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function createNavigationBlock( menuItems ) {
'core/navigation',
{
orientation: 'vertical',
showJustifyControls: false,
},
innerBlocks
);
Expand Down

0 comments on commit 9ebbbab

Please sign in to comment.