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 <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>
Co-authored-by: andrewserong <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
6 people authored Feb 15, 2024
1 parent e3f3c3d commit 3242ca9
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 @@ -76,7 +77,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

1 comment on commit 3242ca9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 3242ca9.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7913952971
📝 Reported issues:

Please sign in to comment.