Skip to content
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
1 change: 1 addition & 0 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ function Layout( { styles } ) {
if ( mode === 'visual' && isListViewOpened ) {
return <ListViewSidebar />;
}

return null;
};

Expand Down
7 changes: 7 additions & 0 deletions packages/edit-post/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ export default function EditPostPreferencesModal() {
) }
label={ __( 'Spotlight mode' ) }
/>
<EnableFeature
featureName="showListViewByDefault"
help={ __(
'Opens the block list view sidebar by default.'
) }
label={ __( 'Always open list view' ) }
/>
<EnableFeature
featureName="showIconLabels"
help={ __( 'Shows text instead of icons.' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
help="Highlights the current block and fades other content."
label="Spotlight mode"
/>
<WithSelect(WithDispatch(BaseOption))
featureName="showListViewByDefault"
help="Opens the block list view sidebar by default."
label="Always open list view"
/>
<WithSelect(WithDispatch(BaseOption))
featureName="showIconLabels"
help="Shows text instead of icons."
Expand Down Expand Up @@ -158,6 +163,11 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
help="Highlights the current block and fades other content."
label="Spotlight mode"
/>
<WithSelect(WithDispatch(BaseOption))
featureName="showListViewByDefault"
help="Opens the block list view sidebar by default."
label="Always open list view"
/>
<WithSelect(WithDispatch(BaseOption))
featureName="showIconLabels"
help="Shows text instead of icons."
Expand Down
7 changes: 7 additions & 0 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,19 @@ export function initializeEditor(
preferredStyleVariations: {},
showBlockBreadcrumbs: true,
showIconLabels: false,
showListViewByDefault: false,
themeStyles: true,
welcomeGuide: true,
welcomeGuideTemplate: true,
} );

dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();

// Check if the block list view should be open by default.
if ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {
dispatch( editPostStore ).setIsListViewOpened( true );
}

registerCoreBlocks();
if ( process.env.IS_GUTENBERG_PLUGIN ) {
__experimentalRegisterExperimentalCoreBlocks( {
Expand Down
7 changes: 7 additions & 0 deletions packages/edit-site/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export default function EditSitePreferencesModal( {
label={ __( 'Show button text labels' ) }
help={ __( 'Show text instead of icons on buttons' ) }
/>
<EnableFeature
featureName="showListViewByDefault"
help={ __(
'Opens the block list view sidebar by default.'
) }
label={ __( 'Always open list view' ) }
/>
</PreferencesModalSection>
),
},
Expand Down
11 changes: 11 additions & 0 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,19 @@ export function reinitializeEditor( target, settings ) {
keepCaretInsideBlock: false,
welcomeGuide: true,
welcomeGuideStyles: true,
shouldListViewOpenByDefault: false,
} );

// Check if the block list view should be open by default.
if (
select( preferencesStore ).get(
'core/edit-site',
'showListViewByDefault'
)
) {
dispatch( editSiteStore ).setIsListViewOpened( true );
}

dispatch( editSiteStore ).updateSettings( settings );

// Keep the defaultTemplateTypes in the core/editor settings too,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ npm run test-e2e:playwright
npm run test-e2e:playwright -- --headed

# Run a single test file.
npm run test-e2e:playwright -- <path_to_test_file>
npm run test-e2e:playwright -- <path_to_test_file> # E.g., npm run test-e2e:playwright -- site-editor/title.spec.js

# Debugging
npm run test-e2e:playwright -- --debug
Expand Down
40 changes: 40 additions & 0 deletions test/e2e/specs/site-editor/block-list-panel-preference.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Block list view', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'emptytheme' );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );

test( 'Should open by default', async ( { page, pageUtils } ) => {
await pageUtils.visitSiteEditor( {
postId: 'emptytheme//index',
postType: 'wp_template',
} );

// Should display the Preview button.
await expect(
page.locator( 'role=region[name="List View"i]' )
).not.toBeVisible();

// Turn on block list view by default.
await page.evaluate( () => {
window.wp.data
.dispatch( 'core/preferences' )
.set( 'core/edit-site', 'showListViewByDefault', true );
} );

await page.reload();

// Should display the Preview button.
await expect(
page.locator( 'role=region[name="List View"i]' )
).toBeVisible();
} );
} );