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: Enable starter pattern modal for all post types #69753

Conversation

himanshupathak95
Copy link
Contributor

@himanshupathak95 himanshupathak95 commented Mar 29, 2025

What?

Closes #69750
This PR fixes the starter pattern modal so it works for all post types, not just pages. It removes the restriction that was limiting the modal to only appear when creating new pages.

Why?

Currently, the starter pattern modal only works when creating a new page, not when creating a new post or other post types. This regression was introduced in PR #66836 and not fully resolved in PR #69081.

The condition that determines whether to show the modal explicitly checks if the current post type is 'page', preventing it from working with posts or other content types even when patterns are properly configured for those types.

How?

This PR removes the post type restriction in the enabled property of the StartPageOptions component, allowing the modal to appear for any post type when patterns are available.

Testing Instructions

  • Set up test patterns for both posts and pages
  • Create a new page (Pages -> Add New)
  • Verify the starter pattern modal appears
  • Create a new post (Posts -> Add New)
    • Without this fix, the modal would not appear
    • With this fix, the modal should now appear

Screencast

Before

Screen.Recording.2025-03-29.at.14.54.09.mov

After

Screen.Recording.2025-03-29.at.15.11.22.mov

@himanshupathak95 himanshupathak95 marked this pull request as ready for review March 29, 2025 09:30
Copy link

github-actions bot commented Mar 29, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @jnweaver.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: jnweaver.

Co-authored-by: himanshupathak95 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Mamaduka <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Regression Related to a regression in the latest release Backport to WP 6.8 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced labels Mar 31, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I think that just removing the post type check isn't the right approach. Because there is another starter modal for the template.

A duplicate modal will be opened if the following conditions are met:

  • When the template is empty
  • The active theme has a starter content that is compatible with both page and template (has Post Types: page, wp_template header meta data)
acf8c22ed874b367bf86f1c3081d896c.mp4

I think we need to add TEMPLATE_POST_TYPE !== getCurrentPostType() check to determine whether the stater pattern modal should be displayed or not.

@Mamaduka
Copy link
Member

I agree with @t-hamano! We shouldn't entirely remove the check.

@Mamaduka
Copy link
Member

Mamaduka commented Apr 1, 2025

@himanshupathak95, do you have time to follow up on this one so I can include the fix in the next RC?

Here's a patch with the changes that @t-hamano suggested:

diff --git packages/editor/src/components/start-page-options/index.js packages/editor/src/components/start-page-options/index.js
index 14d052052e7..a1661ee2fcb 100644
--- packages/editor/src/components/start-page-options/index.js
+++ packages/editor/src/components/start-page-options/index.js
@@ -17,6 +17,7 @@ import { store as interfaceStore } from '@wordpress/interface';
 /**
  * Internal dependencies
  */
+import { TEMPLATE_POST_TYPE } from '../../store/constants';
 import { store as editorStore } from '../../store';
 
 export function useStartPatterns() {
@@ -152,7 +153,8 @@ export default function StartPageOptions() {
 		return {
 			postId: getCurrentPostId(),
 			enabled:
-				choosePatternModalEnabled && 'page' === getCurrentPostType(),
+				choosePatternModalEnabled &&
+				TEMPLATE_POST_TYPE !== getCurrentPostType(),
 		};
 	}, [] );
 

@himanshupathak95
Copy link
Contributor Author

The E2E failure here is unexpected. Triggering the jobs again might fix the failure.

@himanshupathak95 himanshupathak95 force-pushed the fix/69750-starter-pattern-modal-all-post-types branch from ad7f0d3 to 2121c40 Compare April 1, 2025 06:40
@Mamaduka Mamaduka merged commit c6aff30 into WordPress:trunk Apr 1, 2025
59 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.7 milestone Apr 1, 2025
@github-actions github-actions bot removed the Backport to WP 6.8 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Apr 1, 2025
gutenbergplugin pushed a commit that referenced this pull request Apr 1, 2025
Unlinked contributors: jnweaver.

Co-authored-by: himanshupathak95 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Apr 1, 2025
Copy link

github-actions bot commented Apr 1, 2025

I just cherry-picked this PR to the wp/6.8 branch to get it included in the next release: 42af6b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Regression Related to a regression in the latest release
Projects
Development

Successfully merging this pull request may close these issues.

Starter pattern modal only works for 'page' post type - 6.8RC1
3 participants