Skip to content

Commit

Permalink
aria-label equal to a menu name added to navigation block
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz_marzencki committed Jan 30, 2021
1 parent e5a966b commit faa079a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function Navigation( {
hasSubmenuIndicatorSetting = true,
hasItemJustificationControls = attributes.orientation === 'horizontal',
hasListViewModal = true,
menuName,
} ) {
const navIcons = {
left: justifyLeft,
Expand Down Expand Up @@ -200,7 +201,7 @@ function Navigation( {
</PanelBody>
) }
</InspectorControls>
<nav { ...blockProps }>
<nav { ...blockProps } aria-label={ menuName }>
<ul { ...innerBlocksProps } />
</nav>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function useNavigationBlockWithName( menuId ) {
] );

const { saveMenu } = useDispatch( 'core' );
const menuName = menu?.name ?? '(untitled menu)';

useEffect( () => {
if ( menu ) {
Expand All @@ -27,15 +28,16 @@ export default function useNavigationBlockWithName( menuId ) {
}
return (
<>
<BlockEdit { ...props } />
<BlockEdit { ...props } menuName={ menuName } />
<BlockControls>
<ToolbarGroup>
<EditInPlaceControl
label={ menu?.name ?? '(untitled menu)' }
label={ menuName }
onUpdate={ ( value ) => {
saveMenu( {
...menu,
name: value || '(untitled menu)',
name:
value || '(untitled menu)',
} );
} }
/>
Expand All @@ -51,9 +53,12 @@ export default function useNavigationBlockWithName( menuId ) {
'core/edit-navigation/with-menu-name',
withMenuName
);
return () => removeFilter( 'editor.BlockEdit', 'core/edit-navigation/with-menu-name', withMenuName );
return () =>
removeFilter(
'editor.BlockEdit',
'core/edit-navigation/with-menu-name',
withMenuName
);
}
}, [ menuId ] );


}

0 comments on commit faa079a

Please sign in to comment.