Skip to content

Commit

Permalink
Editor: Do not open list view by default on mobile (#59016)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
6 people committed Feb 20, 2024
1 parent d6fdcdf commit 2fc218e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function initializeEditor(
settings,
initialEdits
) {
const isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;
const target = document.getElementById( id );
const root = createRoot( target );

Expand Down Expand Up @@ -77,7 +78,9 @@ export function initializeEditor(

// Check if the block list view should be open by default.
// If `distractionFree` mode is enabled, the block list view should not be open.
// This behavior is disabled for small viewports.
if (
isMediumOrBigger &&
select( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&
! select( preferencesStore ).get( 'core', 'distractionFree' )
) {
Expand Down
4 changes: 4 additions & 0 deletions packages/edit-site/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ import { TEMPLATE_POST_TYPE } from '../utils/constants';
export const setCanvasMode =
( mode ) =>
( { registry, dispatch } ) => {
const isMediumOrBigger =
window.matchMedia( '(min-width: 782px)' ).matches;
registry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );
dispatch( {
type: 'SET_CANVAS_MODE',
mode,
} );
// Check if the block list view should be open by default.
// If `distractionFree` mode is enabled, the block list view should not be open.
// This behavior is disabled for small viewports.
if (
isMediumOrBigger &&
mode === 'edit' &&
registry
.select( preferencesStore )
Expand Down

0 comments on commit 2fc218e

Please sign in to comment.