From 390124807dd56aba9b15d92e3fadc5ea23396a93 Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Tue, 4 Jun 2024 10:27:44 -0500 Subject: [PATCH] Focus canvas from footer breadcrumb click --- .../src/components/block-breadcrumb/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/block-breadcrumb/index.js b/packages/block-editor/src/components/block-breadcrumb/index.js index b1fd13dbf3475a..39d864db81dc84 100644 --- a/packages/block-editor/src/components/block-breadcrumb/index.js +++ b/packages/block-editor/src/components/block-breadcrumb/index.js @@ -12,6 +12,7 @@ import { chevronRightSmall, Icon } from '@wordpress/icons'; import BlockTitle from '../block-title'; import { store as blockEditorStore } from '../../store'; import { unlock } from '../../lock-unlock'; +import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs'; /** * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb. @@ -37,6 +38,10 @@ function BlockBreadcrumb( { rootLabelText } ) { }, [] ); const rootLabel = rootLabelText || __( 'Document' ); + // We don't care about this specific ref, but this is a way + // to get a ref within the editor canvas so we can focus it later. + const blockRef = useBlockRef( clientId ); + /* * Disable reason: The `list` ARIA role is redundant but * Safari+VoiceOver won't announce the list otherwise. @@ -60,7 +65,11 @@ function BlockBreadcrumb( { rootLabelText } ) {