Skip to content

Commit

Permalink
Improve accessible Name of the Navigation Offcanvas List View
Browse files Browse the repository at this point in the history
Update packages/block-library/src/navigation/edit/menu-inspector-controls.js

Co-authored-by: Dave Smith <getdavemail@gmail.com>

Update packages/block-library/src/navigation/edit/menu-inspector-controls.js

Co-authored-by: Alex Stine <alex.stine@yourtechadvisors.com>

switch to using a description rather than another label

Update packages/block-library/src/navigation/edit/menu-inspector-controls.js

Co-authored-by: Dave Smith <getdavemail@gmail.com>
  • Loading branch information
Ben Dwyer and getdave committed Jan 31, 2023
1 parent 09052a2 commit dd6d28f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/block-editor/src/components/off-canvas-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
* @param {boolean} props.showBlockMovers Flag to enable block movers
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
* @param {Object} props.LeafMoreMenu Optional more menu substitution.
* @param {string} props.description Optional accessible description for the tree grid component.
* @param {Object} ref Forwarded ref
*/
function OffCanvasEditor(
{ id, blocks, showBlockMovers = false, isExpanded = false, LeafMoreMenu },
{
id,
blocks,
showBlockMovers = false,
isExpanded = false,
LeafMoreMenu,
description = __( 'Block navigation structure' ),
},
ref
) {
const { clientIdsTree, draggedClientIds, selectedClientIds } =
Expand Down Expand Up @@ -208,7 +216,7 @@ function OffCanvasEditor(
onCollapseRow={ collapseRow }
onExpandRow={ expandRow }
onFocusRow={ focusRow }
applicationAriaLabel={ __( 'Block navigation structure' ) }
aria-description={ description }
>
<ListViewContext.Provider value={ contextValue }>
<ListViewBranch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Spinner,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
Expand All @@ -22,6 +22,7 @@ import NavigationMenuSelector from './navigation-menu-selector';
import { LeafMoreMenu } from '../leaf-more-menu';
import { unlock } from '../../experiments';
import DeletedNavigationWarning from './deleted-navigation-warning';
import useNavigationMenu from '../use-navigation-menu';

/* translators: %s: The name of a menu. */
const actionLabel = __( "Switch to '%s'" );
Expand All @@ -43,6 +44,7 @@ const MainContent = ( {
},
[ clientId ]
);
const { navigationMenu } = useNavigationMenu( currentMenuId );

if ( currentMenuId && isNavigationMenuMissing ) {
return <p>{ __( 'Select or create a menu' ) }</p>;
Expand All @@ -56,11 +58,19 @@ const MainContent = ( {
return <Spinner />;
}

const description = navigationMenu
? sprintf(
/* translators: %s: The name of a menu. */
__( 'Structure for navigation menu: %s' ),
navigationMenu?.title || __('Untitled menu')
)
: __( 'You have not yet created any menus. Displaying a list of your Pages' );
return (
<OffCanvasEditor
blocks={ clientIdsTree }
isExpanded={ true }
LeafMoreMenu={ LeafMoreMenu }
description={ description }
/>
);
};
Expand Down

0 comments on commit dd6d28f

Please sign in to comment.