diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js
index 51abac654da29..daf789cb0a2ec 100644
--- a/packages/edit-post/src/index.js
+++ b/packages/edit-post/src/index.js
@@ -70,6 +70,7 @@ export function initializeEditor(
showBlockBreadcrumbs: true,
showIconLabels: false,
showListViewByDefault: false,
+ enableChoosePatternModal: true,
isPublishSidebarEnabled: true,
} );
diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js
index 4ed5b96e3844d..1aceecc4d8b1f 100644
--- a/packages/edit-site/src/index.js
+++ b/packages/edit-site/src/index.js
@@ -79,6 +79,7 @@ export function initializeEditor( id, settings ) {
openPanels: [ 'post-status' ],
showBlockBreadcrumbs: true,
showListViewByDefault: false,
+ enableChoosePatternModal: true,
} );
if ( window.__experimentalMediaProcessing ) {
diff --git a/packages/edit-site/src/posts.js b/packages/edit-site/src/posts.js
index 9e2582ac23328..78d823b56c4c1 100644
--- a/packages/edit-site/src/posts.js
+++ b/packages/edit-site/src/posts.js
@@ -72,6 +72,7 @@ export function initializePostsDashboard( id, settings ) {
openPanels: [ 'post-status' ],
showBlockBreadcrumbs: true,
showListViewByDefault: false,
+ enableChoosePatternModal: true,
} );
dispatch( editSiteStore ).updateSettings( settings );
diff --git a/packages/editor/src/components/preferences-modal/index.js b/packages/editor/src/components/preferences-modal/index.js
index e7cc637dd0aed..a8cfd8245522c 100644
--- a/packages/editor/src/components/preferences-modal/index.js
+++ b/packages/editor/src/components/preferences-modal/index.js
@@ -26,6 +26,7 @@ import PageAttributesCheck from '../page-attributes/check';
import PostTypeSupportCheck from '../post-type-support-check';
import { store as editorStore } from '../../store';
import { unlock } from '../../lock-unlock';
+import { useStartPatterns } from '../start-page-options';
const {
PreferencesModal,
@@ -57,6 +58,7 @@ export default function EditorPreferencesModal( { extraSections = {} } ) {
const { setIsListViewOpened, setIsInserterOpened } =
useDispatch( editorStore );
const { set: setPreference } = useDispatch( preferencesStore );
+ const hasStarterPatterns = !! useStartPatterns().length;
const sections = useMemo(
() =>
@@ -97,6 +99,16 @@ export default function EditorPreferencesModal( { extraSections = {} } ) {
'Allow right-click contextual menus'
) }
/>
+ { hasStarterPatterns && (
+
+ ) }
{
- // filter patterns without postTypes declared if the current postType is page
- // or patterns that declare the current postType in its post type array.
+ if ( ! blockPatternsWithPostContentBlockType?.length ) {
+ return [];
+ }
+
+ /*
+ * Filter patterns without postTypes declared if the current postType is page
+ * or patterns that declare the current postType in its post type array.
+ */
return blockPatternsWithPostContentBlockType.filter( ( pattern ) => {
return (
( postType === 'page' && ! pattern.postTypes ) ||
@@ -110,30 +118,24 @@ function StartPageOptionsModal( { onClose } ) {
export default function StartPageOptions() {
const [ isClosed, setIsClosed ] = useState( false );
- const { shouldEnableModal, postType, postId } = useSelect( ( select ) => {
- const {
- isEditedPostDirty,
- isEditedPostEmpty,
- getCurrentPostType,
- getCurrentPostId,
- } = select( editorStore );
- const _postType = getCurrentPostType();
-
- return {
- shouldEnableModal:
- ! isEditedPostDirty() &&
- isEditedPostEmpty() &&
- TEMPLATE_POST_TYPE !== _postType,
- postType: _postType,
- postId: getCurrentPostId(),
- };
+ const shouldEnableModal = useSelect( ( select ) => {
+ const { isEditedPostDirty, isEditedPostEmpty, getCurrentPostType } =
+ select( editorStore );
+ const preferencesModalActive =
+ select( interfaceStore ).isModalActive( 'editor/preferences' );
+ const choosePatternModalEnabled = select( preferencesStore ).get(
+ 'core',
+ 'enableChoosePatternModal'
+ );
+ return (
+ choosePatternModalEnabled &&
+ ! preferencesModalActive &&
+ ! isEditedPostDirty() &&
+ isEditedPostEmpty() &&
+ TEMPLATE_POST_TYPE !== getCurrentPostType()
+ );
}, [] );
- useEffect( () => {
- // Should reset the modal state when navigating to a new page/post.
- setIsClosed( false );
- }, [ postType, postId ] );
-
if ( ! shouldEnableModal || isClosed ) {
return null;
}