From 831c206766277aee5fd49fcbcd008a6a8bfa9ba9 Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Fri, 14 Jun 2024 13:40:52 -0500 Subject: [PATCH] Refactor finding focusable wrapper --- .../block-editor/src/components/block-tools/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/block-tools/index.js b/packages/block-editor/src/components/block-tools/index.js index 698f340fc2669..48f678751816d 100644 --- a/packages/block-editor/src/components/block-tools/index.js +++ b/packages/block-editor/src/components/block-tools/index.js @@ -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(); }