Skip to content

Commit

Permalink
Styles Navigation Screen: close style book using location (#51365)
Browse files Browse the repository at this point in the history
* Using location to determine whether to reset `editorCanvasContainerView` instead selector to avoid e2e fails. playwright runs faster than the useEffect resetting the value.

* path is a property.

* adding location?.path to dep array
  • Loading branch information
ramonjd authored Jun 9, 2023
1 parent 238d9a9 commit be4cc1b
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import {
__experimentalItemGroup as ItemGroup,
__experimentalNavigatorButton as NavigatorButton,
__experimentalUseNavigator as useNavigator,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { layout, symbol, navigation, styles, page } from '@wordpress/icons';
import { useDispatch, useSelect } from '@wordpress/data';
import { useDispatch } from '@wordpress/data';

import { useEffect } from '@wordpress/element';

Expand All @@ -22,20 +23,17 @@ import { store as editSiteStore } from '../../store';
import SidebarNavigationScreenNavigationMenuButton from '../sidebar-navigation-screen-navigation-menus/navigator-button';

export default function SidebarNavigationScreenMain() {
const editorCanvasContainerView = useSelect( ( select ) => {
return unlock( select( editSiteStore ) ).getEditorCanvasContainerView();
}, [] );

const { location } = useNavigator();
const { setEditorCanvasContainerView } = unlock(
useDispatch( editSiteStore )
);

// Clear the editor canvas container view when accessing the main navigation screen.
useEffect( () => {
if ( editorCanvasContainerView ) {
if ( location?.path === '/' ) {
setEditorCanvasContainerView( undefined );
}
}, [ editorCanvasContainerView, setEditorCanvasContainerView ] );
}, [ setEditorCanvasContainerView, location?.path ] );

return (
<SidebarNavigationScreen
Expand Down

0 comments on commit be4cc1b

Please sign in to comment.