Skip to content

Commit

Permalink
Unlock useShouldContextualToolbarShow outside of the component (#50612)
Browse files Browse the repository at this point in the history
* Edit Post: Unlock useShouldContextualToolbarShow outside of the component
* Feedback
  • Loading branch information
Mamaduka authored May 15, 2023
1 parent adefb89 commit f8d74a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down Expand Up @@ -67,8 +69,6 @@ function HeaderToolbar() {
};
}, [] );

const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );

const isLargeViewport = useViewportMatch( 'medium' );
const isWideViewport = useViewportMatch( 'wide' );
const {
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/header-edit-mode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import {
} from '../editor-canvas-container';
import { unlock } from '../../private-apis';

const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );

const preventDefault = ( event ) => {
event.preventDefault();
};
Expand Down Expand Up @@ -126,7 +128,6 @@ export default function HeaderEditMode() {
[ setIsListViewOpened, isListViewOpen ]
);

const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );
const {
shouldShowContextualToolbar,
canFocusHiddenToolbar,
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-widgets/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -72,7 +74,6 @@ function Header() {
[ setIsListViewOpened, isListViewOpen ]
);

const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );
const {
shouldShowContextualToolbar,
canFocusHiddenToolbar,
Expand Down

0 comments on commit f8d74a6

Please sign in to comment.