diff --git a/packages/block-editor/src/components/block-tools/zoom-out-mode-inserters.js b/packages/block-editor/src/components/block-tools/zoom-out-mode-inserters.js index 79f8be3f9cfe97..ca8496373a3cbf 100644 --- a/packages/block-editor/src/components/block-tools/zoom-out-mode-inserters.js +++ b/packages/block-editor/src/components/block-tools/zoom-out-mode-inserters.js @@ -92,6 +92,14 @@ function ZoomOutModeInserters() { { + // Hotfix for a bug where focus is not transferred to the sidebar if the + // block library is already open. + const blockLibrary = document.querySelector( + '[aria-label="Block Library"]' + ); + + // Bug: this only sets the tab to `patterns` when opening the inserter, + // it does not update the open inserter to the patterns tab. setInserterIsOpened( { rootClientId: sectionRootClientId, insertionIndex: index, @@ -101,6 +109,12 @@ function ZoomOutModeInserters() { showInsertionPoint( sectionRootClientId, index, { operation: 'insert', } ); + + // If the block library was available before we opened it with `setInserterIsOpened`, we need to + // send focus to the block library. + if ( blockLibrary ) { + blockLibrary.focus(); + } } } /> ) }