Skip to content

Commit

Permalink
Apply useShouldContextualToolbarShow to edit site header navigable to…
Browse files Browse the repository at this point in the history
…olbar (#50349)
  • Loading branch information
jeryj authored May 11, 2023
1 parent 2f77022 commit cb87840
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/edit-site/src/components/header-edit-mode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
__experimentalPreviewOptions as PreviewOptions,
NavigableToolbar,
store as blockEditorStore,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { PinnedItems } from '@wordpress/interface';
Expand Down Expand Up @@ -125,6 +126,19 @@ export default function HeaderEditMode() {
[ setIsListViewOpened, isListViewOpen ]
);

const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );
const {
shouldShowContextualToolbar,
canFocusHiddenToolbar,
fixedToolbarCanBeFocused,
} = useShouldContextualToolbarShow();
// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
const blockToolbarCanBeFocused =
shouldShowContextualToolbar ||
canFocusHiddenToolbar ||
fixedToolbarCanBeFocused;

const hasDefaultEditorCanvasView = ! useHasEditorCanvasContainer();

const isFocusMode = templateType === 'wp_template_part';
Expand All @@ -150,6 +164,9 @@ export default function HeaderEditMode() {
<NavigableToolbar
className="edit-site-header-edit-mode__start"
aria-label={ __( 'Document tools' ) }
shouldUseKeyboardFocusShortcut={
! blockToolbarCanBeFocused
}
>
<div className="edit-site-header-edit-mode__toolbar">
<ToolbarItem
Expand Down

1 comment on commit cb87840

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in cb87840.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4946958594
📝 Reported issues:

Please sign in to comment.