Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Do not open list view by default on mobile #59016

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
youknowriad marked this conversation as resolved.
Show resolved Hide resolved
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.
youknowriad marked this conversation as resolved.
Show resolved Hide resolved
// 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
Loading