Skip to content

Restoring a Draft version in the admin unpublishes the live document #18389

Closed

Description

@jimmi-joensson

Describe the Bug

On a collection with versions: { drafts: true }, restoring a Draft version from the admin version view unpublishes the live document.

The Restore button only offers "Restore as draft" when the viewed version is not a draft:

const canRestoreAsDraft = status !== 'draft' && collectionConfig?.versions?.drafts

For a Draft version the only option is "Restore this version", which sends POST /api/<collection>/versions/<id>?draft=false. restoreVersionOperation then calls db.updateOne on the main collection with the version's data, including _status: 'draft'. The published document is overwritten and the public page (queried without draft) disappears.

POST /api/<collection>/versions/<id>?draft=true restores the same Draft version safely (new draft version, main document untouched), but no admin button sends it for Draft versions.

Expected: restoring a Draft version creates a new draft and leaves the published document live, like "Restore as draft" does for Published versions.

Related observations:

  • setDraft(true) from "Restore as draft" is never reset. If the confirmation modal is cancelled, the next click on "Restore this version" still sends draft=true.
  • For globals, restoreVersionOperation in packages/payload/src/globals/operations/restoreVersion.ts always calls db.updateGlobal, so draft=true also overwrites the live global (it only forces _status: 'draft').

The fix we applied locally as a pnpm patch on @payloadcms/[email protected] (dist/views/Version/Restore/index.js): when the version is a Draft and the collection has drafts, the main button restores with draft=true and is labelled "Restore as draft"; the main button also resets draft on click.

const restoresAsDraftOnly = status === 'draft' && Boolean(collectionConfig?.versions?.drafts)
// Button
onClick: () => [setDraft(restoresAsDraftOnly), toggleModal(modalSlug)],
children: restoresAsDraftOnly ? t('version:restoreAsDraft') : t('version:restoreThisVersion'),

The same code is in packages/ui/src/views/Version/Restore/index.tsx on main.

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/blob/main/packages/ui/src/views/Version/Restore/index.tsx

Reproduction Steps

  1. Collection with versions: { drafts: true }. Create a document and publish it.
  2. Save two drafts with different titles (Draft A, Draft B).
  3. Open Versions, select the Draft A version. Only "Restore this version" is offered.
  4. Restore it.
  5. The main document now has _status: 'draft'; payload.find({ collection, draft: false }) / the public page no longer returns the published content (404 on a frontend that only renders published documents).

With POST /api/<collection>/versions/<DraftA id>?draft=true instead, the published document stays live and the latest draft has Draft A's content.

Which area(s) are affected?

area: ui, area: core

Environment Info

Payload: 3.89.0 (@payloadcms/next, @payloadcms/ui, payload)
Next.js: 15.4.11
Node.js: 22
Database: @payloadcms/db-sqlite and @payloadcms/db-postgres

Activity

  1. added
    area: core
    area: ui
    on Sep 29, 2026
  2. erikmartus commented on Sep 30, 2026

    @erikmartus

    We encountered an issue related to this that patching as described fixed for us. In addition to unpublishing, if the draft version you attempt to restore from has any incomplete required fields the restore will fail because it attempts to do a full published validation since the action is attempting to write to the main table row.

  3. jacobsfletch commented on Oct 21, 2026

    @jacobsfletch
    Member

    In addition to unpublishing, if the draft version you attempt to restore from has any incomplete required fields the restore will fail because it attempts to do a full published validation since the action is attempting to write to the main table row.

    We're considering making Restore as draft the standard for all version restores when drafts are enabled. See #18892.

  4. added a commit that references this issue on Oct 21, 2026
    4859c0b
  5. github-actions commented on Oct 22, 2026

    @github-actions
    Contributor

    🚀 This is included in version v4.0.0-beta.4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugarea: corearea: ui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions