Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation: Surface menu name in the List View next to the Navigation block #68446

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading