Skip to content

Commit

Permalink
Fix focus toolbar shortcut when breadcrumb and toolbar are both in DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
jeryj committed Nov 29, 2023
1 parent cd2393d commit ede3596
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/block-editor/src/components/block-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const BlockToolbar = ( {
blockEditingMode,
blockType,
hasParents,
isKeyboardFocusShortcutActive,
isValid,
isVisual,
showParentSelector,
Expand All @@ -57,6 +58,7 @@ const BlockToolbar = ( {
getBlockParents,
getSelectedBlockClientIds,
isBlockValid,
isNavigationMode,
getBlockRootClientId,
getBlockEditingMode,
} = select( blockEditorStore );
Expand All @@ -76,6 +78,8 @@ const BlockToolbar = ( {
getBlockType( getBlockName( selectedBlockClientId ) ),

hasParents: parents.length,
isKeyboardFocusShortcutActive:
isFixed || ( ! isFixed && ! isNavigationMode() ),
isValid: selectedBlockClientIds.every( ( id ) =>
isBlockValid( id )
),
Expand Down Expand Up @@ -136,6 +140,7 @@ const BlockToolbar = ( {
return (
<NavigableToolbar
focusEditorOnEscape
shouldUseKeyboardFocusShortcut={ isKeyboardFocusShortcutActive }
className={ classes }
/* translators: accessibility text for the block toolbar */
aria-label={ __( 'Block tools' ) }
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ test.describe( 'Focus toolbar shortcut (alt + F10)', () => {

// Test: Focus the block toolbar from empty block
await editor.insertBlock( { name: 'core/paragraph' } );
// This fails if we don't wait for the block toolbar to show.
await expect(
toolbarUtils.blockToolbarParagraphButton
).toBeVisible();
await toolbarUtils.moveToToolbarShortcut();
await expect(
toolbarUtils.blockToolbarParagraphButton
Expand Down

0 comments on commit ede3596

Please sign in to comment.