-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add duplicate post action #60637
Add duplicate post action #60637
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +842 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
This would make things much simpler in the post editor too. Otherwise, if the current page has unsaved changes, the user would see the "Leave site?" dialog after duplicating which would be quite disruptive. |
e0983be
to
87d377c
Compare
87d377c
to
965afb7
Compare
Hi @jameskoster, |
Thanks @jorgefilipecosta! One tiny change request... After duplicating a page in the editor you have to click twice to edit it because the menu remains open. Would it be possible to auto-close the menu when you click "Duplicate"? |
085afce
to
03e41fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I duplicate a post or page from inside the block editor, the content is not copied.
It just creates a new draft with the same title followed by (Copy).
03e41fc
to
d685e81
Compare
Flaky tests detected in d685e81. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8805341896
|
Noting that I found that it just showed as "copy" without the other title and could also replicate the content wasn't brought over: |
functionality works as advertised for me 👍. Tested using WordPress Playground PR Previewer I like how the revisions extended handles UI/UX wise https://github.com/WordPress/revisions-extended sharing here for reference. |
d685e81
to
130c4fd
Compare
Hi @carolinan, good catch on content not being copied it was a regression during the iterations that is now fixed. |
@jameskoster the menu now auto closes and the double click is not necessary. |
@ajitbohra thank you for the review and for sharing a related UI. I guess for now we can keep the simple approach of an edit button on the notices to avoid complexity on the actions API but in the future, we may explore other possibilities. |
@jorgefilipecosta agree keeping it simple for initial implementation makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jorgefilipecosta this is working well for me :)
130c4fd
to
62a2e5d
Compare
The bug reported was fixed. Thank you for catching this!
Hi everyone, creator of Yoast Duplicate Post here :) |
Hi @enricobattocchi, Given that the Duplicate action has more interest manifested in extending it compared to the other actions, I made the action only available in the plugin for now at #61192. This makes sure it is not released in core by mistake before the extensibility API's are ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorgefilipecosta I was hoping this would get A11Y reviewed before merged, hopefully some basic testing was done as I don't see any E2E tests.
One question I had is how the new posts are actually being created? Are we actually grabbing the post content from a store and posting it to the rest API? I'm not actually sure how the internals work in this area of Gutenberg. Creating a new post or page is one thing but actually having to create a new post or page then copy the content, meta, excerpt, and anything else, that's another. If we're making one huge batch POST to the rest API, I expect this to fail on shared hosts due to small max HTTP POST limits. If this is going to work, I would think PHP is required here to handle this at the database level directly without having to send this data in through rest.
Part of #59689.
Adds the duplicate post-action.
@jameskoster After we duplicate a post when we are with the post opened in the editor should we navigate to the new post or keep the current post open?
Testing Instructions