Skip to content

fix(next): preserve published content when restoring drafts - #19540

Merged
jacobsfletch merged 1 commit into
payloadcms:3.xfrom
Maartenb111:backport/18394-to-3.x
Nov 16, 2026
Merged

jacobsfletch merged 1 commit into
payloadcms:3.xfrom
Maartenb111:backport/18394-to-3.x

Conversation

@Maartenb111

@Maartenb111 Maartenb111 commented Nov 12, 2026 •

Copy link
Copy Markdown

Identical to #18394, back-ported for 3.x.

Backport of payloadcms#18394. On 3.x the restore button lives in packages/next.

A draft version of a collection with drafts is now restored as a draft,
and the main button reads "Restore as draft", so restoring it no longer
unpublishes the live document (payloadcms#18389). The main button also sets the
draft flag on every click and Cancel resets it, so a cancelled "Restore
as draft" no longer turns a later "Restore this version" into a draft
restore.
@github-actions github-actions Bot added the v3 label Nov 12, 2026
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The restore controls now select draft mode based on the selected version. E2E tests cover restoring a historical draft, canceling draft restoration, and restoring a version normally.

Changes: Version restore flow

Layer / File(s) Summary
Draft-aware restore selection and validation
packages/next/src/views/Version/Restore/index.tsx, test/versions/e2e.spec.ts
Draft-only versions select draft mode and show “Restore as draft.” Canceling resets draft mode based on the selected version. E2E tests check the draft and live API results for draft and regular restoration.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related issues

  • payloadcms/payload#18926: The issue covers default restoration behavior for draft and published versions, which this change also addresses.

Possibly related PRs

  • payloadcms/payload#18892: This PR changes the restore-as-draft behavior in the UI restore component. Its draft-mode rules differ from the rules in this change.

Suggested reviewers: jarrodmflesch

Merge Risk: Minimal · up to 29289

This change makes restoring a draft version restore it as a draft, and stops a cancelled "Restore as draft" from carrying over to a later regular restore. No merge-blocking risk was found, and regression tests are included.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description says the PR is identical to #18394 and back-ported for 3.x. It relates to the changeset, which backports the same restore fix. Level of detail is not important for this check. It names…
Title check Passed The title "fix(next): preserve published content when restoring drafts" matches the main change. The raw summary and objectives show that restoring a draft version in a collection with drafts no longe…
Full details: Description check

Explanation

The description says the PR is identical to #18394 and back-ported for 3.x. It relates to the changeset, which backports the same restore fix. Level of detail is not important for this check. It names the source PR and the target branch, so it is related to the changes in the Restore component and its E2E tests.

Full details: Title check

Explanation

The title "fix(next): preserve published content when restoring drafts" matches the main change. The raw summary and objectives show that restoring a draft version in a collection with drafts no longer overwrites the published document. The main button now restores as draft, and cancelling the confirmation resets the draft flag. The title is specific and concise, and it uses the conventional commit form. It omits the cancel-reset fix, which is a secondary part of the change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d50e6e0 and 2928941.

Files selected for processing: 2

  • packages/next/src/views/Version/Restore/index.tsx
  • test/versions/e2e.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@jacobsfletch jacobsfletch left a comment

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.

Thank you @Maartenb111

@jacobsfletch jacobsfletch changed the title fix(next): preserve published content when restoring drafts (3.x) fix(next): preserve published content when restoring drafts Nov 16, 2026
@jacobsfletch
jacobsfletch merged commit 0778894 into payloadcms:3.x Nov 16, 2026
183 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.94.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants