From d35ec8923101f6af84e6faace5134f1ba605b784 Mon Sep 17 00:00:00 2001 From: Ella Date: Wed, 4 Dec 2024 10:12:24 +0100 Subject: [PATCH] Select the block wrapper --- .../use-block-props/use-focus-first-element.js | 9 +++++---- .../use-block-props/use-selected-block-event-handlers.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js b/packages/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js index 26f7cca2990d8..40262c99e19dd 100644 --- a/packages/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js +++ b/packages/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js @@ -43,10 +43,6 @@ export function useFocusFirstElement( { clientId, initialPosition } ) { return; } - if ( initialPosition === undefined || initialPosition === null ) { - return; - } - if ( ! ref.current ) { return; } @@ -58,6 +54,11 @@ export function useFocusFirstElement( { clientId, initialPosition } ) { return; } + if ( initialPosition === undefined || initialPosition === null ) { + ref.current.focus(); + return; + } + // Find all tabbables within node. const textInputs = focus.tabbable .find( ref.current ) diff --git a/packages/block-editor/src/components/block-list/use-block-props/use-selected-block-event-handlers.js b/packages/block-editor/src/components/block-list/use-block-props/use-selected-block-event-handlers.js index bcf05eadc0daf..be666dc12d34a 100644 --- a/packages/block-editor/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +++ b/packages/block-editor/src/components/block-list/use-block-props/use-selected-block-event-handlers.js @@ -116,7 +116,7 @@ export function useEventHandlers( { clientId, isSelected } ) { } if ( nextClientId ) { - selectBlock( nextClientId ); + selectBlock( nextClientId, null ); } } } else {