From 96f387fb7107d92bfaefec7c9a9164fe1fc07469 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Thu, 6 Aug 2020 13:53:17 -0700 Subject: [PATCH] Use select mode whenever blocks are unselected --- packages/edit-site/src/components/editor/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index 80fc9a4359334..46472f3175896 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -57,6 +57,7 @@ function Editor() { page, template, select, + hasSelectedBlock, } = useSelect( ( _select ) => { const { isFeatureActive, @@ -96,6 +97,9 @@ function Editor() { : null, select: _select, entityId: _entityId, + hasSelectedBlock: !! _select( + 'core/block-editor' + ).getSelectedBlock(), }; }, [] ); const { editEntityRecord } = useDispatch( 'core' ); @@ -103,10 +107,12 @@ function Editor() { const { setNavigationMode } = useDispatch( 'core/block-editor' ); - // Set editor to navigation mode on component mount. + // Set editor to navigation mode whenever no blocks are selected. useEffect( () => { - setNavigationMode( true ); - }, [ true ] ); + if ( ! hasSelectedBlock ) { + setNavigationMode( true ); + } + }, [ hasSelectedBlock ] ); const inlineStyles = useResizeCanvas( deviceType );