From a7f1991ba959a047917070f8dda26fc65baaabfa Mon Sep 17 00:00:00 2001 From: Zebulan Stanphill Date: Thu, 24 Sep 2020 09:35:36 -0500 Subject: [PATCH] Stop auto-focusing Navigation block in Navigation screen. (#25592) I also added a JSDoc comment while I was at it. --- .../src/components/editor/block-view.js | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/edit-navigation/src/components/editor/block-view.js b/packages/edit-navigation/src/components/editor/block-view.js index 416f38c9fe900..93106399c8f16 100644 --- a/packages/edit-navigation/src/components/editor/block-view.js +++ b/packages/edit-navigation/src/components/editor/block-view.js @@ -1,26 +1,16 @@ /** * WordPress dependencies */ -import { useSelect, useDispatch } from '@wordpress/data'; -import { useEffect } from '@wordpress/element'; -import { WritingFlow, ObserveTyping, BlockList } from '@wordpress/block-editor'; +import { BlockList, ObserveTyping, WritingFlow } from '@wordpress/block-editor'; import { Spinner } from '@wordpress/components'; +/** + * The current navigation rendered in the form of a core Navigation block. + * + * @param {Object} props Component props. + * @param {boolean} props.isPending Whether the navigation post has loaded. + */ export default function BlockView( { isPending } ) { - const rootClientId = useSelect( - ( select ) => select( 'core/block-editor' ).getBlocks()[ 0 ]?.clientId, - [] - ); - - const { selectBlock } = useDispatch( 'core/block-editor' ); - - // Select the root Navigation block when it becomes available. - useEffect( () => { - if ( rootClientId ) { - selectBlock( rootClientId ); - } - }, [ rootClientId, selectBlock ] ); - return (
{ isPending ? (