Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Multiple Tooltips from Focus Toolbar Shortcut on Site Editor #50349

Merged
merged 1 commit into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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