From 1e32b15f5fd0b4fd8e9de7e2a3459fc88b0028c8 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Tue, 7 May 2024 16:24:12 +0900 Subject: [PATCH] See what happens when we don't select blocks when entering zoom out mode --- packages/block-editor/src/store/actions.js | 46 +--------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index 61acae16fcca2d..456a679c8f6bd1 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -33,8 +33,6 @@ import { __experimentalUpdateSettings, privateRemoveBlocks, } from './private-actions'; -import { STORE_NAME } from './constants'; -import { unlock } from '../lock-unlock'; /** @typedef {import('../components/use-on-block-drop/types').WPDropOperation} WPDropOperation */ @@ -1608,49 +1606,7 @@ export const setNavigationMode = */ export const __unstableSetEditorMode = ( mode ) => - ( { dispatch, select, registry } ) => { - // When switching to zoom-out mode, we need to select the parent section - if ( mode === 'zoom-out' ) { - const firstSelectedClientId = select.getBlockSelectionStart(); - const allBlocks = select.getBlocks(); - - const { sectionRootClientId } = unlock( - registry.select( STORE_NAME ).getSettings() - ); - if ( sectionRootClientId ) { - const sectionClientIds = - select.getBlockOrder( sectionRootClientId ); - const lastSectionClientId = - sectionClientIds[ sectionClientIds.length - 1 ]; - if ( sectionClientIds ) { - if ( firstSelectedClientId ) { - const parents = select.getBlockParents( - firstSelectedClientId - ); - const firstSectionClientId = parents.find( ( parent ) => - sectionClientIds.includes( parent ) - ); - if ( firstSectionClientId ) { - dispatch.selectBlock( firstSectionClientId ); - } else { - dispatch.selectBlock( lastSectionClientId ); - } - } else { - dispatch.selectBlock( lastSectionClientId ); - } - } - } else if ( firstSelectedClientId ) { - const rootClientId = select.getBlockHierarchyRootClientId( - firstSelectedClientId - ); - dispatch.selectBlock( rootClientId ); - } else { - // If there's no block selected and no sectionRootClientId, select the last root block. - const lastRootBlock = allBlocks[ allBlocks.length - 1 ]; - dispatch.selectBlock( lastRootBlock?.clientId ); - } - } - + ( { dispatch } ) => { dispatch( { type: 'SET_EDITOR_MODE', mode } ); if ( mode === 'navigation' ) {