From 05ea598ab6865ae5dcd20fa183959bc50af3738d Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Fri, 18 Oct 2024 13:11:48 -0500 Subject: [PATCH] Hotfix for moving focus to block library from sidebar --- .../block-tools/zoom-out-mode-inserters.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 a60ca7f3967741..569905fba11e9f 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 @@ -70,6 +70,12 @@ function ZoomOutModeInserters() { > { + // Hotfix for wp/6.7 where focus is not transferred to the sidebar if the + // block library is already open. + const blockLibrary = document.querySelector( + '[aria-label="Block Library"]' + ); + setInserterIsOpened( { rootClientId: sectionRootClientId, insertionIndex: index + 1, @@ -79,6 +85,12 @@ function ZoomOutModeInserters() { showInsertionPoint( sectionRootClientId, index + 1, { 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(); + } } } />