From 626c3fa98d7bcbdbc425d9b968055619640bbdec Mon Sep 17 00:00:00 2001 From: Marin Atanasov <8436925+tyxla@users.noreply.github.com> Date: Wed, 4 Sep 2024 18:00:20 +0300 Subject: [PATCH] Inserter: Fix subtle media insertion error (#65057) * Inserter: Fix subtle media insertion error * Remove unnecessary ref optional chaining Co-authored-by: Marco Ciampini * Reformat --------- Co-authored-by: Marco Ciampini Co-authored-by: tyxla Co-authored-by: ciampo Co-authored-by: Mamaduka --- packages/block-editor/src/components/inserter/menu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index b884ea97588459..faf2c20514f67a 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -101,12 +101,12 @@ function InserterMenu( window.requestAnimationFrame( () => { if ( ! shouldFocusBlock && - ! blockTypesTabRef?.current.contains( + ! blockTypesTabRef.current?.contains( ref.current.ownerDocument.activeElement ) ) { // There has been a focus loss, so focus the first button in the block types tab - blockTypesTabRef?.current.querySelector( 'button' ).focus(); + blockTypesTabRef.current?.querySelector( 'button' ).focus(); } } ); },