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: Unify list view open preference #57504

Merged
merged 1 commit into from
Jan 3, 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
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
4 changes: 2 additions & 2 deletions test/e2e/specs/site-editor/list-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.describe( 'Site Editor List View', () => {
).toBeHidden();

// Turn on block list view by default.
await editor.setPreferences( 'core/edit-site', {
await editor.setPreferences( 'core', {
showListViewByDefault: true,
} );

Expand All @@ -41,7 +41,7 @@ test.describe( 'Site Editor List View', () => {
).toBeVisible();

// The preferences cleanup.
await editor.setPreferences( 'core/edit-site', {
await editor.setPreferences( 'core', {
showListViewByDefault: false,
} );
} );
Expand Down
Loading