From 767b8dda5589f9e1007e29c3cb224bd384f68b2d Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 2 Feb 2023 11:34:01 +0000 Subject: [PATCH] Navigation Block List View: Improve the accessible Name of the Tree Grid inside the component. (#47031) * Improve accessible Name of the Navigation Offcanvas List View Update packages/block-library/src/navigation/edit/menu-inspector-controls.js Co-authored-by: Dave Smith Update packages/block-library/src/navigation/edit/menu-inspector-controls.js Co-authored-by: Alex Stine 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 * Apply suggestions from code review * disable linting * fix linter --------- Co-authored-by: Ben Dwyer Co-authored-by: Dave Smith --- .../src/components/off-canvas-editor/index.js | 13 +++++++++++-- .../src/navigation/edit/menu-inspector-controls.js | 14 +++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/off-canvas-editor/index.js b/packages/block-editor/src/components/off-canvas-editor/index.js index 267357411a3eae..593a2c2e97ca33 100644 --- a/packages/block-editor/src/components/off-canvas-editor/index.js +++ b/packages/block-editor/src/components/off-canvas-editor/index.js @@ -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 } = @@ -208,7 +216,8 @@ function OffCanvasEditor( onCollapseRow={ collapseRow } onExpandRow={ expandRow } onFocusRow={ focusRow } - applicationAriaLabel={ __( 'Block navigation structure' ) } + // eslint-disable-next-line jsx-a11y/aria-props + aria-description={ description } > { __( 'Select or create a menu' ) }

; @@ -56,11 +58,21 @@ const MainContent = ( { return ; } + 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 ( ); };