Skip to content

Commit

Permalink
Editor: Unify list view open preference (#57504)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Jan 3, 2024
1 parent a278bb8 commit 84715c0
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default function EditPostPreferencesModal() {
) }
<PreferencesModalSection title={ __( 'Interface' ) }>
<EnableFeature
scope="core"
featureName="showListViewByDefault"
help={ __(
'Opens the block list view sidebar by default.'
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export function initializeEditor(
isPublishSidebarEnabled: true,
openPanels: [ 'post-status' ],
preferredStyleVariations: {},
showListViewByDefault: false,
themeStyles: true,
welcomeGuide: true,
welcomeGuideTemplate: true,
Expand All @@ -72,14 +71,15 @@ export function initializeEditor(
allowRightClickOverrides: true,
showBlockBreadcrumbs: true,
showIconLabels: false,
showListViewByDefault: false,
} );

dispatch( blocksStore ).reapplyBlockTypeFilters();

// Check if the block list view should be open by default.
// If `distractionFree` mode is enabled, the block list view should not be open.
if (
select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) &&
select( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&
! select( editPostStore ).isFeatureActive( 'distractionFree' )
) {
dispatch( editorStore ).setIsListViewOpened( true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function EditorCanvasContainer( {
).getEditorCanvasContainerView();

const _showListViewByDefault = select( preferencesStore ).get(
'core/edit-site',
'core',
'showListViewByDefault'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default function EditSitePreferencesModal() {
content: (
<PreferencesModalSection title={ __( 'Interface' ) }>
<EnableFeature
scope="core"
featureName="showListViewByDefault"
help={ __(
'Opens the block list view sidebar by default.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function GlobalStylesSidebar() {
'visual' === select( editSiteStore ).getEditorMode();
const _isEditCanvasMode = 'edit' === getCanvasMode();
const _showListViewByDefault = select( preferencesStore ).get(
'core/edit-site',
'core',
'showListViewByDefault'
);
const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export function initializeEditor( id, settings ) {
welcomeGuideStyles: true,
welcomeGuidePage: true,
welcomeGuideTemplate: true,
showListViewByDefault: false,
} );

dispatch( preferencesStore ).setDefaults( 'core', {
allowRightClickOverrides: true,
keepCaretInsideBlock: false,
showBlockBreadcrumbs: true,
showListViewByDefault: false,
} );

dispatch( interfaceStore ).setDefaultComplementaryArea(
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const setCanvasMode =
mode === 'edit' &&
registry
.select( preferencesStore )
.get( 'core/edit-site', 'showListViewByDefault' ) &&
.get( 'core', 'showListViewByDefault' ) &&
! registry
.select( preferencesStore )
.get( 'core/edit-site', 'distractionFree' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default function convertEditorSettings( data ) {
'keepCaretInsideBlock',
'showBlockBreadcrumbs',
'showIconLabels',
'showListViewByDefault',
];

settingsToMoveToCore.forEach( ( setting ) => {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/block-renaming.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test.describe( 'Block Renaming', () => {
pageUtils,
} ) => {
// Turn on block list view by default.
await editor.setPreferences( 'core/edit-site', {
await editor.setPreferences( 'core', {
showListViewByDefault: true,
} );

Expand Down