diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js
index 22ebad383884e9..edf820a2f92643 100644
--- a/packages/edit-site/src/components/global-styles/ui.js
+++ b/packages/edit-site/src/components/global-styles/ui.js
@@ -21,6 +21,7 @@ import { moreVertical } from '@wordpress/icons';
import { store as coreStore } from '@wordpress/core-data';
import { useEffect } from '@wordpress/element';
import { usePrevious } from '@wordpress/compose';
+import { privateApis as routerPrivateApis } from '@wordpress/router';
/**
* Internal dependencies
@@ -52,6 +53,7 @@ const SLOT_FILL_NAME = 'GlobalStylesMenu';
const { useGlobalStylesReset } = unlock( blockEditorPrivateApis );
const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } =
createSlotFill( SLOT_FILL_NAME );
+const { useLocation } = unlock( routerPrivateApis );
function GlobalStylesActionMenu() {
const [ canReset, onReset ] = useGlobalStylesReset();
@@ -329,6 +331,8 @@ function NavigationSync( { path: parentPath, onPathChange, children } ) {
function GlobalStylesUI( { path, onPathChange } ) {
const blocks = getBlockTypes();
+ const { query } = useLocation();
+ const { canvas } = query;
const editorCanvasContainerView = useSelect(
( select ) =>
unlock( select( editSiteStore ) ).getEditorCanvasContainerView(),
@@ -440,7 +444,7 @@ function GlobalStylesUI( { path, onPathChange } ) {
-
+ { 'edit' === canvas && }
);
}
diff --git a/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js b/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js
index 980f20c49821b0..d1b356ab7193e1 100644
--- a/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js
+++ b/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js
@@ -3,6 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { useMemo, useState } from '@wordpress/element';
+import { useDispatch } from '@wordpress/data';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { useViewportMatch } from '@wordpress/compose';
import {
@@ -19,6 +20,7 @@ import Page from '../page';
import { unlock } from '../../lock-unlock';
import StyleBook from '../style-book';
import { STYLE_BOOK_COLOR_GROUPS } from '../style-book/constants';
+import { store as editSiteStore } from '../../store';
const { useLocation, useHistory } = unlock( routerPrivateApis );
const { Menu } = unlock( componentsPrivateApis );
@@ -26,6 +28,7 @@ const { Menu } = unlock( componentsPrivateApis );
const GlobalStylesPageActions = ( {
isStyleBookOpened,
setIsStyleBookOpened,
+ setIsStyleBookClosed,
} ) => {
return (