Skip to content

Commit

Permalink
Refactor finding focusable wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jeryj authored and scruffian committed Jun 19, 2024
1 parent 25af62f commit 831c206
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,10 @@ export default function BlockTools( {

// The region is provivided by the editor, not the block-editor.
// We should send focus to the region if one is available to reuse the
// same interface for navigating landmarks.
const editorRegion = editorCanvas?.closest( '[role="region"]' );

// If no region is available, use the canvas instead.
const focusableWrapper = editorRegion || editorCanvas;
// same interface for navigating landmarks. If no region is available,
// use the canvas instead.
const focusableWrapper =
editorCanvas?.closest( '[role="region"]' ) ?? editorCanvas;

focusableWrapper.focus();
}
Expand Down

0 comments on commit 831c206

Please sign in to comment.