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 Screen: Update sidebar #31821

Merged
merged 8 commits into from
May 20, 2021
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
38 changes: 14 additions & 24 deletions packages/e2e-tests/specs/experiments/navigation-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,11 @@ describe( 'Navigation editor', () => {
await pressKeyWithModifier( 'primary', 'A' );
}
} );

describe( 'Menu name editor', () => {
const initialMenuName = 'Main Menu';
const navigationNameEditorSelector =
'.block-editor-block-inspector .edit-navigation-name-editor__text-control';
'.edit-navigation-name-editor__text-control';
const inputSelector = `${ navigationNameEditorSelector } input`;
let navigatorNameEditor, input;
beforeEach( async () => {
Expand All @@ -406,12 +407,6 @@ describe( 'Navigation editor', () => {
] );

await visitNavigationEditor();
const navBlock = await page.waitForSelector(
'div[aria-label="Block: Navigation"]'
);
const boundingBox = await navBlock.boundingBox();
// click on the navigation editor placeholder.
await page.mouse.click( boundingBox.x + 25, boundingBox.y + 25 );

navigatorNameEditor = await page.$( navigationNameEditorSelector );
input = await page.$( inputSelector );
Expand Down Expand Up @@ -445,6 +440,7 @@ describe( 'Navigation editor', () => {
] );

await input.focus();

// clear input
const oldName = await page.$eval(
inputSelector,
Expand All @@ -460,17 +456,16 @@ describe( 'Navigation editor', () => {
);
await saveButton.click();
await page.waitForSelector( '.components-snackbar' );
const menuNameButton = await page.waitForXPath(
'//button[contains(@aria-label, "Edit menu name: ' +
newName +
'" ) ]'
const headerSubtitle = await page.waitForSelector(
'.edit-navigation-header__subtitle'
);
expect( menuNameButton ).toBeTruthy();
const menuNameButtonText = await menuNameButton.evaluate(
expect( headerSubtitle ).toBeTruthy();
const headerSubtitleText = await headerSubtitle.evaluate(
( element ) => element.innerText
);
expect( menuNameButtonText ).toBe( newName );
expect( headerSubtitleText ).toBe( `Editing: ${ newName }` );
} );

it( 'does not save a menu name upon clicking save button when name is empty', async () => {
const menuPostResponse = {
id: 4,
Expand Down Expand Up @@ -501,13 +496,14 @@ describe( 'Navigation editor', () => {
);
await saveButton.click();
await page.waitForSelector( '.components-snackbar' );
const menuNameButton = await page.waitForXPath(
'//button[contains(@aria-label, "Edit menu name" ) ]'
const headerSubtitle = await page.waitForSelector(
'.edit-navigation-header__subtitle'
);
const menuNameButtonText = await menuNameButton.evaluate(
expect( headerSubtitle ).toBeTruthy();
const headerSubtitleText = await headerSubtitle.evaluate(
( element ) => element.innerText
);
expect( menuNameButtonText ).toBe( oldName );
expect( headerSubtitleText ).toBe( `Editing: ${ oldName }` );
} );
} );

Expand All @@ -531,12 +527,6 @@ describe( 'Navigation editor', () => {
] );

await visitNavigationEditor();

// Select the navigation block, so inspector controls are visible.
const navigationBlock = await page.waitForSelector(
'div[aria-label="Block: Navigation"]'
);
await navigationBlock.click();
} );

afterEach( async () => {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

39 changes: 18 additions & 21 deletions packages/edit-navigation/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ import {
} from '../../hooks';
import ErrorBoundary from '../error-boundary';
import NavigationEditorShortcuts from './shortcuts';
import Sidebar from './sidebar';
import Sidebar from '../sidebar';
import Header from '../header';
import Notices from '../notices';
import Editor from '../editor';
import InspectorAdditions from '../inspector-additions';
import UnsavedChangesWarning from './unsaved-changes-warning';
import { store as editNavigationStore } from '../../store';

Expand Down Expand Up @@ -175,24 +174,6 @@ export default function Layout( { blockEditorSettings } ) {
}
blocks={ blocks }
/>
<InspectorAdditions
isManageLocationsModalOpen={
isManageLocationsModalOpen
}
openManageLocationsModal={
openManageLocationsModal
}
closeManageLocationsModal={
closeManageLocationsModal
}
onSelectMenu={ selectMenu }
menus={ menus }
menuId={ selectedMenuId }
onDeleteMenu={ deleteMenu }
isMenuBeingDeleted={
isMenuBeingDeleted
}
/>
</div>
</BlockTools>
) }
Expand All @@ -205,7 +186,23 @@ export default function Layout( { blockEditorSettings } ) {
)
}
/>
<Sidebar hasPermanentSidebar={ hasPermanentSidebar } />
<Sidebar
onSelectMenu={ selectMenu }
menus={ menus }
menuId={ selectedMenuId }
onDeleteMenu={ deleteMenu }
isMenuBeingDeleted={ isMenuBeingDeleted }
hasPermanentSidebar={ hasPermanentSidebar }
isManageLocationsModalOpen={
isManageLocationsModalOpen
}
openManageLocationsModal={
openManageLocationsModal
}
closeManageLocationsModal={
closeManageLocationsModal
}
/>
</IsMenuNameControlFocusedContext.Provider>
<UnsavedChangesWarning />
</BlockEditorProvider>
Expand Down
65 changes: 0 additions & 65 deletions packages/edit-navigation/src/components/layout/sidebar.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/edit-navigation/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
left: auto;

// Hide the toggle as the sidebar should be permanently open.
.interface-complementary-area-header {
.edit-navigation-sidebar__panel-tabs > button {
display: none;
}
}
Expand Down
10 changes: 2 additions & 8 deletions packages/edit-navigation/src/components/name-display/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import {
useMenuEntityProp,
IsMenuNameControlFocusedContext,
} from '../../hooks';
import {
COMPLEMENTARY_AREA_SCOPE,
COMPLEMENTARY_AREA_ID,
} from '../../constants';
import { SIDEBAR_SCOPE, SIDEBAR_MENU } from '../../constants';

export default function NameDisplay() {
const { enableComplementaryArea } = useDispatch( interfaceStore );
Expand All @@ -42,10 +39,7 @@ export default function NameDisplay() {
menuName
) }
onClick={ () => {
enableComplementaryArea(
COMPLEMENTARY_AREA_SCOPE,
COMPLEMENTARY_AREA_ID
);
enableComplementaryArea( SIDEBAR_SCOPE, SIDEBAR_MENU );
setIsMenuNameEditFocused( true );
} }
>
Expand Down
Loading