Skip to content

Commit

Permalink
Hotfix for moving focus to block library from sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
jeryj committed Oct 18, 2024
1 parent 737fac0 commit 165d2e7
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ function ZoomOutModeInserters() {
<ZoomOutModeInserterButton
isVisible={ isSelected || isHovered }
onClick={ () => {
// 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,
Expand All @@ -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();
}
} }
/>
) }
Expand Down

0 comments on commit 165d2e7

Please sign in to comment.