diff --git a/packages/block-editor/src/components/tool-selector/index.js b/packages/block-editor/src/components/tool-selector/index.js index 0a51fbd4325f7..b8b46d17c6d7b 100644 --- a/packages/block-editor/src/components/tool-selector/index.js +++ b/packages/block-editor/src/components/tool-selector/index.js @@ -31,7 +31,6 @@ const selectIcon = ( ); function ToolSelector( props, ref ) { - const [ isSimpleMode, setIsSimpleMode ] = useState( false ); const [ originalTemplateLocks, setOriginalTemplateLocks ] = useState( {} ); const { mode, blocksWithinMainBlockClientIds, getBlockAttributes } = useSelect( ( select ) => { @@ -75,7 +74,7 @@ function ToolSelector( props, ref ) { <> { if ( newMode === 'simple' ) { const originalLocks = {}; @@ -94,8 +93,6 @@ function ToolSelector( props, ref ) { templateLock: 'contentOnly', } ); - __unstableSetEditorMode( 'edit' ); - setIsSimpleMode( true ); } else { // Restore the original templateLock attributes blocksWithinMainBlockClientIds.forEach( @@ -108,9 +105,8 @@ function ToolSelector( props, ref ) { } ); } ); - __unstableSetEditorMode( newMode ); - setIsSimpleMode( false ); } + __unstableSetEditorMode( newMode ); } } choices={ [ { diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index ebd310b3de9d3..46bc147f69f2a 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -1714,20 +1714,30 @@ export const __unstableSetEditorMode = dispatch( { type: 'SET_EDITOR_MODE', mode } ); - if ( mode === 'navigation' ) { - speak( - __( - 'You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.' - ) - ); - } else if ( mode === 'edit' ) { - speak( - __( - 'You are currently in edit mode. To return to the navigation mode, press Escape.' - ) - ); - } else if ( mode === 'zoom-out' ) { - speak( __( 'You are currently in zoom-out mode.' ) ); + switch ( mode ) { + case 'navigation': + speak( + __( + 'You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.' + ) + ); + break; + case 'edit': + speak( + __( + 'You are currently in edit mode. To return to the navigation mode, press Escape.' + ) + ); + break; + case 'zoom-out': + speak( __( 'You are currently in zoom-out mode.' ) ); + break; + case 'simple': + speak( __( 'You are currently in simple editing mode.' ) ); + break; + default: + // Optional: handle other cases or do nothing + break; } };