From 8a671748f1f2bc81c64b871d0fadac50736b7ee8 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Mon, 3 Jul 2023 17:25:26 +1000 Subject: [PATCH] Exit template focus when opening the W menu --- packages/edit-site/src/store/private-actions.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/store/private-actions.js b/packages/edit-site/src/store/private-actions.js index 952c1852ae305c..1b97959277760b 100644 --- a/packages/edit-site/src/store/private-actions.js +++ b/packages/edit-site/src/store/private-actions.js @@ -11,7 +11,7 @@ import { store as preferencesStore } from '@wordpress/preferences'; */ export const setCanvasMode = ( mode ) => - ( { registry, dispatch } ) => { + ( { registry, dispatch, select } ) => { registry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' ); dispatch( { type: 'SET_CANVAS_MODE', @@ -26,6 +26,10 @@ export const setCanvasMode = ) { dispatch.setIsListViewOpened( true ); } + // Switch focus away from editing the template when switching to view mode. + if ( mode === 'view' && select.isPage() ) { + dispatch.setHasPageContentFocus( true ); + } }; /**