Skip to content

Commit

Permalink
Fix issue with navigation structure panel being always initially closed
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Apr 15, 2020
1 parent d8be3a9 commit a796f3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 6 additions & 1 deletion packages/edit-navigation/src/components/menu-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BlockEditorKeyboardShortcuts,
BlockEditorProvider,
} from '@wordpress/block-editor';
import { useViewportMatch } from '@wordpress/compose';

/**
* Internal dependencies
Expand All @@ -16,6 +17,7 @@ import NavigationStructurePanel from './navigation-structure-panel';

export default function MenuEditor( { menuId, blockEditorSettings } ) {
const [ blocks, setBlocks, saveBlocks ] = useNavigationBlocks( menuId );
const isLargeViewport = useViewportMatch( 'medium' );

return (
<div className="edit-navigation-menu-editor">
Expand All @@ -34,7 +36,10 @@ export default function MenuEditor( { menuId, blockEditorSettings } ) {
>
<BlockEditorKeyboardShortcuts />
<MenuEditorShortcuts saveBlocks={ saveBlocks } />
<NavigationStructurePanel blocks={ blocks } />
<NavigationStructurePanel
blocks={ blocks }
initialOpen={ isLargeViewport }
/>
<BlockEditorPanel menuId={ menuId } saveBlocks={ saveBlocks } />
</BlockEditorProvider>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
*/
import { __experimentalBlockNavigationList } from '@wordpress/block-editor';
import { Panel, PanelBody } from '@wordpress/components';
import { useViewportMatch } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';

export default function NavigationStructurePanel( { blocks } ) {
const isLargeViewport = useViewportMatch( 'medium' );

export default function NavigationStructurePanel( { blocks, initialOpen } ) {
return (
<Panel>
<PanelBody
title={ __( 'Navigation structure' ) }
initialOpen={ isLargeViewport }
initialOpen={ initialOpen }
>
{ !! blocks.length && (
<__experimentalBlockNavigationList
Expand Down

0 comments on commit a796f3c

Please sign in to comment.