Skip to content

Commit e53ba3b

Browse files
youknowriadntsekourasaaronrobertshawandrewserongt-hamano
committed
Editor: Do not open list view by default on mobile (#59016)
Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
1 parent 9b48e86 commit e53ba3b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/edit-post/src/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function initializeEditor(
4949
settings,
5050
initialEdits
5151
) {
52+
const isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;
5253
const target = document.getElementById( id );
5354
const root = createRoot( target );
5455

@@ -77,7 +78,9 @@ export function initializeEditor(
7778

7879
// Check if the block list view should be open by default.
7980
// If `distractionFree` mode is enabled, the block list view should not be open.
81+
// This behavior is disabled for small viewports.
8082
if (
83+
isMediumOrBigger &&
8184
select( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&
8285
! select( preferencesStore ).get( 'core', 'distractionFree' )
8386
) {

packages/edit-site/src/store/private-actions.js

+4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ import { TEMPLATE_POST_TYPE } from '../utils/constants';
2222
export const setCanvasMode =
2323
( mode ) =>
2424
( { registry, dispatch } ) => {
25+
const isMediumOrBigger =
26+
window.matchMedia( '(min-width: 782px)' ).matches;
2527
registry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );
2628
dispatch( {
2729
type: 'SET_CANVAS_MODE',
2830
mode,
2931
} );
3032
// Check if the block list view should be open by default.
3133
// If `distractionFree` mode is enabled, the block list view should not be open.
34+
// This behavior is disabled for small viewports.
3235
if (
36+
isMediumOrBigger &&
3337
mode === 'edit' &&
3438
registry
3539
.select( preferencesStore )

0 commit comments

Comments
 (0)