Skip to content

Commit

Permalink
Show submenus option in all cases for navigation block
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmarZaidi committed Jan 6, 2025
1 parent ea52a61 commit 6671d85
Showing 1 changed file with 35 additions and 44 deletions.
79 changes: 35 additions & 44 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,8 @@ function Navigation( {
hasUncontrolledInnerBlocks,
uncontrolledInnerBlocks,
isInnerBlockSelected,
innerBlocks,
} = useInnerBlocks( clientId );

const hasSubmenus = !! innerBlocks.find(
( block ) => block.name === 'core/navigation-submenu'
);

const {
replaceInnerBlocks,
selectBlock,
Expand Down Expand Up @@ -654,47 +649,43 @@ function Navigation( {
label={ __( 'Always' ) }
/>
</ToggleGroupControl>
{ hasSubmenus && (
<>
<h3>{ __( 'Submenus' ) }</h3>
<ToggleControl
__nextHasNoMarginBottom
checked={ openSubmenusOnClick }
onChange={ ( value ) => {
setAttributes( {
openSubmenusOnClick: value,
...( value && {
showSubmenuIcon: true,
} ), // Make sure arrows are shown when we toggle this on.
} );
} }
label={ __( 'Open on click' ) }
/>
<h3>{ __( 'Submenus' ) }</h3>
<ToggleControl
__nextHasNoMarginBottom
checked={ openSubmenusOnClick }
onChange={ ( value ) => {
setAttributes( {
openSubmenusOnClick: value,
...( value && {
showSubmenuIcon: true,
} ), // Make sure arrows are shown when we toggle this on.
} );
} }
label={ __( 'Open on click' ) }
/>

<ToggleControl
__nextHasNoMarginBottom
checked={ showSubmenuIcon }
onChange={ ( value ) => {
setAttributes( {
showSubmenuIcon: value,
} );
} }
disabled={ attributes.openSubmenusOnClick }
label={ __( 'Show arrow' ) }
/>
<ToggleControl
__nextHasNoMarginBottom
checked={ showSubmenuIcon }
onChange={ ( value ) => {
setAttributes( {
showSubmenuIcon: value,
} );
} }
disabled={ attributes.openSubmenusOnClick }
label={ __( 'Show arrow' ) }
/>

{ submenuAccessibilityNotice && (
<div>
<Notice
spokenMessage={ null }
status="warning"
isDismissible={ false }
>
{ submenuAccessibilityNotice }
</Notice>
</div>
) }
</>
{ submenuAccessibilityNotice && (
<div>
<Notice
spokenMessage={ null }
status="warning"
isDismissible={ false }
>
{ submenuAccessibilityNotice }
</Notice>
</div>
) }
</PanelBody>
) }
Expand Down

0 comments on commit 6671d85

Please sign in to comment.