Skip to content

Template activation: duplicate action should be available outside GB#72513

Merged
ellatrix merged 5 commits intotrunkfrom
fix/duplicate-action-core
Oct 21, 2025
Merged

Template activation: duplicate action should be available outside GB#72513
ellatrix merged 5 commits intotrunkfrom
fix/duplicate-action-core

Conversation

@ellatrix
Copy link
Copy Markdown
Member

What?

The duplicate activation is not available outside of GB. Apparently it should be removed for pages, so I'm explicitly removing it for that post type and leaving things otherwise the same.

Why?

It's an essential part of the template activation feature.

How?

Testing Instructions

Edit the code and remove the globalThis.IS_GUTENBERG_PLUGIN negation. Verify that you can't duplicate pages. Verify that you can duplicate templates.

Testing Instructions for Keyboard

Screenshots or screencast

Before After

@ellatrix ellatrix added [Type] Bug An existing feature does not function as intended Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) labels Oct 21, 2025
duplicatePost;

// @ts-ignore
if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick: we could have a single if ( ! globalThis.IS_GUTENBERG_PLUGIN && postType === 'page')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can't, I get an error then

Copy link
Copy Markdown
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

Worked well in my tests forcing IS_GUTENBERG_PLUGIN to false duplicate was still avaliable in templates, template parts and patterns, but not on pages. with IS_GUTENBERG_PLUGIN unchanged it is also available on pages.

canCreate &&
duplicatePost
: undefined,
canDuplicate,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wouldn't this make the duplicate action available for any post type (but wp_block, wp_template_part, page) in WordPress?

Note these actions are also used in the inspector of the post editor:

Screenshot 2025-10-21 at 11 28 52

We could enabling it just for templates, regardless of environment (gutenberg/wordpress).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch @oandregal, it is making it available for posts too on the inspector. cc: @ellatrix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, I didn't know this affects the post editor

duplicatePost;

// @ts-ignore
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 21, 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.

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

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: priethor <priethor@git.wordpress.org>

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

@ellatrix ellatrix force-pushed the fix/duplicate-action-core branch from 36a0990 to 2e2b758 Compare October 21, 2025 11:03
Copy link
Copy Markdown
Contributor

@priethor priethor left a comment

Choose a reason for hiding this comment

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

The failing tests are unrelated to this PR and started failing in trunk earlier today, seemingly after #72487. Let's merge this without those tests passing to get ready for Beta1.

@ellatrix
Copy link
Copy Markdown
Member Author

Yes

Notice:   2 failed
    [chromium] › test/e2e/specs/editor/various/color-support.spec.js:11:6 › Link color in themes › should apply selected link color in editor and frontend 
    [chromium] › test/e2e/specs/editor/various/content-only-lock.spec.js:80:2 › Content-only lock › should be able to automatically stop temporarily modify as blocks when an outside block is selected 

These are failing on trunk too and we need this PR to get merged and included in a package asap. Let's merge. I will skip the performance test too.

@ellatrix ellatrix merged commit e86dd9d into trunk Oct 21, 2025
32 of 33 checks passed
@ellatrix ellatrix deleted the fix/duplicate-action-core branch October 21, 2025 11:47
@github-actions github-actions Bot added this to the Gutenberg 22.0 milestone Oct 21, 2025
priethor added a commit that referenced this pull request Oct 21, 2025
…72513)

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: priethor < priethor@git.wordpress.org>
@priethor
Copy link
Copy Markdown
Contributor

I just cherry-picked this PR to the wp/latest branch to get it included in the next release: a735e7b

priethor added a commit that referenced this pull request Oct 21, 2025
…72513)

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: priethor < priethor@git.wordpress.org>
@priethor
Copy link
Copy Markdown
Contributor

I just cherry-picked this PR to the release/21.9 branch to get it included in the next release: 2d4bf41

@priethor priethor removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Oct 21, 2025
ellatrix added a commit that referenced this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants