File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
packages/editor/src/components/preview-dropdown Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import { ActionItem } from '@wordpress/interface';
2626 * Internal dependencies
2727 */
2828import { store as editorStore } from '../../store' ;
29+ import { store as blockEditorStore } from '@wordpress/block-editor' ;
2930import PostPreviewButton from '../post-preview-button' ;
3031
3132export default function PreviewDropdown ( { forceIsAutosaveable, disabled } ) {
@@ -44,6 +45,12 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
4445 } ;
4546 } , [ ] ) ;
4647 const { setDeviceType } = useDispatch ( editorStore ) ;
48+ const { __unstableSetEditorMode } = useDispatch ( blockEditorStore ) ;
49+
50+ const handleDevicePreviewChange = ( newDeviceType ) => {
51+ setDeviceType ( newDeviceType ) ;
52+ __unstableSetEditorMode ( 'edit' ) ;
53+ } ;
4754
4855 const isMobile = useViewportMatch ( 'medium' , '<' ) ;
4956 if ( isMobile ) {
@@ -113,7 +120,7 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
113120 < MenuItemsChoice
114121 choices = { choices }
115122 value = { deviceType }
116- onSelect = { setDeviceType }
123+ onSelect = { handleDevicePreviewChange }
117124 />
118125 </ MenuGroup >
119126 { isTemplate && (
You can’t perform that action at this time.
0 commit comments