Skip to content

Commit

Permalink
Navigation: Surface menu name in the List View next to the `Navig…
Browse files Browse the repository at this point in the history
…ation block` (#68446)


Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
5 people authored Jan 13, 2025
1 parent d3758ce commit dc76c9a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
20 changes: 20 additions & 0 deletions packages/block-library/src/navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
};

Expand Down
5 changes: 4 additions & 1 deletion test/e2e/specs/editor/blocks/navigation-list-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down
6 changes: 5 additions & 1 deletion test/e2e/specs/site-editor/navigation-editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand All @@ -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,
} );

Expand Down

0 comments on commit dc76c9a

Please sign in to comment.