diff --git a/packages/block-library/src/navigation/index.js b/packages/block-library/src/navigation/index.js index d0405be794ffe8..36156e5f45bbaa 100644 --- a/packages/block-library/src/navigation/index.js +++ b/packages/block-library/src/navigation/index.js @@ -3,6 +3,9 @@ */ import { __ } from '@wordpress/i18n'; import { navigation as icon } from '@wordpress/icons'; +import { select } from '@wordpress/data'; +import { store as coreStore } from '@wordpress/core-data'; +import { decodeEntities } from '@wordpress/html-entities'; /** * Internal dependencies @@ -52,6 +55,23 @@ export const settings = { }, edit, save, + __experimentalLabel: ( { ref } ) => { + if ( ! ref ) { + return; + } + + const navigation = select( coreStore ).getEditedEntityRecord( + 'postType', + 'wp_navigation', + ref + ); + + if ( ! navigation?.title ) { + return; + } + + return decodeEntities( navigation.title ); + }, deprecated, }; diff --git a/test/e2e/specs/editor/blocks/navigation-list-view.spec.js b/test/e2e/specs/editor/blocks/navigation-list-view.spec.js index 2f9963169a5230..47313590f65794 100644 --- a/test/e2e/specs/editor/blocks/navigation-list-view.spec.js +++ b/test/e2e/specs/editor/blocks/navigation-list-view.spec.js @@ -555,7 +555,10 @@ test.describe( 'Navigation block - List view editing', () => { await editor.openDocumentSettingsSidebar(); - await page.getByLabel( 'Test Menu' ).click(); + await page + .getByRole( 'tabpanel' ) + .getByRole( 'button', { name: 'Test Menu' } ) + .click(); await page.keyboard.press( 'ArrowUp' ); diff --git a/test/e2e/specs/site-editor/navigation-editor.spec.js b/test/e2e/specs/site-editor/navigation-editor.spec.js index 64a80e814d6298..2ceaea06ec2d44 100644 --- a/test/e2e/specs/site-editor/navigation-editor.spec.js +++ b/test/e2e/specs/site-editor/navigation-editor.spec.js @@ -40,6 +40,10 @@ test.describe( 'Editing Navigation Menus', () => { canvas: 'edit', } ); + await expect( + page.getByRole( 'button', { name: 'Document Overview' } ) + ).toBeVisible(); + // Open List View. await pageUtils.pressKeys( 'access+o' ); @@ -54,7 +58,7 @@ test.describe( 'Editing Navigation Menus', () => { await expect( listView ).toBeVisible(); const navBlockNode = listView.getByRole( 'link', { - name: 'Navigation', + name: 'Primary Menu', exact: true, } );