From 44a040cae0bbbfb3bce9b6bb22d8cecd13700317 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Sat, 13 May 2023 14:01:17 +0400 Subject: [PATCH 1/2] Edit Post: Unlock useShouldContextualToolbarShow outside of the component --- .../edit-post/src/components/header/header-toolbar/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/edit-post/src/components/header/header-toolbar/index.js b/packages/edit-post/src/components/header/header-toolbar/index.js index c479741317459..337c27bed00d9 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.js @@ -26,6 +26,8 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; import { store as editPostStore } from '../../../store'; import { unlock } from '../../../private-apis'; +const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis ); + const preventDefault = ( event ) => { event.preventDefault(); }; @@ -67,8 +69,6 @@ function HeaderToolbar() { }; }, [] ); - const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis ); - const isLargeViewport = useViewportMatch( 'medium' ); const isWideViewport = useViewportMatch( 'wide' ); const { From 762d7f545150647e74846f24e21bffa51d46c155 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 15 May 2023 19:30:38 +0400 Subject: [PATCH 2/2] Feedback --- packages/edit-site/src/components/header-edit-mode/index.js | 3 ++- packages/edit-widgets/src/components/header/index.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/header-edit-mode/index.js b/packages/edit-site/src/components/header-edit-mode/index.js index 94ff901203e0c..0878cb4faae2d 100644 --- a/packages/edit-site/src/components/header-edit-mode/index.js +++ b/packages/edit-site/src/components/header-edit-mode/index.js @@ -45,6 +45,8 @@ import { } from '../editor-canvas-container'; import { unlock } from '../../private-apis'; +const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis ); + const preventDefault = ( event ) => { event.preventDefault(); }; @@ -126,7 +128,6 @@ export default function HeaderEditMode() { [ setIsListViewOpened, isListViewOpen ] ); - const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis ); const { shouldShowContextualToolbar, canFocusHiddenToolbar, diff --git a/packages/edit-widgets/src/components/header/index.js b/packages/edit-widgets/src/components/header/index.js index 8bd1e226aeda6..e2691f9c74c43 100644 --- a/packages/edit-widgets/src/components/header/index.js +++ b/packages/edit-widgets/src/components/header/index.js @@ -25,6 +25,8 @@ import useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area import { store as editWidgetsStore } from '../../store'; import { unlock } from '../../private-apis'; +const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis ); + function Header() { const isMediumViewport = useViewportMatch( 'medium' ); const inserterButton = useRef(); @@ -72,7 +74,6 @@ function Header() { [ setIsListViewOpened, isListViewOpen ] ); - const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis ); const { shouldShowContextualToolbar, canFocusHiddenToolbar,