From 211052cd6ff504e0fc010909e7580c361c136328 Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 5 Dec 2024 15:06:04 +0100 Subject: [PATCH] Preserve original selectBlock behaviour --- .../block-list/use-block-props/use-focus-first-element.js | 6 +++++- .../block-editor/src/components/writing-flow/use-input.js | 2 +- 2 files changed, 6 insertions(+), 2 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 40262c99e19ddf..d5131e12f02977 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,6 +43,10 @@ export function useFocusFirstElement( { clientId, initialPosition } ) { return; } + if ( initialPosition === undefined || initialPosition === null ) { + return; + } + if ( ! ref.current ) { return; } @@ -54,7 +58,7 @@ export function useFocusFirstElement( { clientId, initialPosition } ) { return; } - if ( initialPosition === undefined || initialPosition === null ) { + if ( initialPosition === true ) { ref.current.focus(); return; } diff --git a/packages/block-editor/src/components/writing-flow/use-input.js b/packages/block-editor/src/components/writing-flow/use-input.js index 5f87ca335c8257..204c2c4913df81 100644 --- a/packages/block-editor/src/components/writing-flow/use-input.js +++ b/packages/block-editor/src/components/writing-flow/use-input.js @@ -159,7 +159,7 @@ export default function useInput() { if ( nextClientId ) { event.preventDefault(); - selectBlock( nextClientId, null ); + selectBlock( nextClientId, true ); } } }