From 5f081dd4d3b0de173ff103e3bc70b17c099f43cc Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Fri, 28 Jun 2024 09:40:16 -0500 Subject: [PATCH] conditionally call focus, as getEditorRegion could return null --- packages/block-editor/src/components/block-breadcrumb/index.js | 2 +- packages/block-editor/src/components/block-tools/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-breadcrumb/index.js b/packages/block-editor/src/components/block-breadcrumb/index.js index 70f038181237b4..b3f2d3dee12013 100644 --- a/packages/block-editor/src/components/block-breadcrumb/index.js +++ b/packages/block-editor/src/components/block-breadcrumb/index.js @@ -74,7 +74,7 @@ function BlockBreadcrumb( { rootLabelText } ) { clearSelectedBlock(); - getEditorRegion( blockEditor ).focus(); + getEditorRegion( blockEditor )?.focus(); } } > { rootLabel } diff --git a/packages/block-editor/src/components/block-tools/index.js b/packages/block-editor/src/components/block-tools/index.js index 5cde3cccaf57e5..5e5f9190a0ebda 100644 --- a/packages/block-editor/src/components/block-tools/index.js +++ b/packages/block-editor/src/components/block-tools/index.js @@ -162,7 +162,7 @@ export default function BlockTools( { ) { event.preventDefault(); clearSelectedBlock(); - getEditorRegion( __unstableContentRef.current ).focus(); + getEditorRegion( __unstableContentRef.current )?.focus(); } } else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) { // If focus is currently within a text field, such as a rich text block or other editable field,