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 a16640b commit 05ea598
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ function ZoomOutModeInserters() {
>
<ZoomOutModeInserterButton
onClick={ () => {
// 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,
Expand All @@ -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();
}
} }
/>
</BlockPopoverInbetween>
Expand Down

0 comments on commit 05ea598

Please sign in to comment.