Repository navigation
Description
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?.draftsFor 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 sendsdraft=true.- For globals,
restoreVersionOperationinpackages/payload/src/globals/operations/restoreVersion.tsalways callsdb.updateGlobal, sodraft=truealso 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
Reproduction Steps
- Collection with
versions: { drafts: true }. Create a document and publish it. - Save two drafts with different titles (Draft A, Draft B).
- Open Versions, select the Draft A version. Only "Restore this version" is offered.
- Restore it.
- 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
erikmartus commentedon Sep 30, 2026
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.
jacobsfletch commentedon Oct 21, 2026
We're considering making
Restore as draftthe standard for all version restores when drafts are enabled. See #18892.fix(ui): preserve published content when restoring drafts (#18394)
github-actions commentedon Oct 22, 2026
🚀 This is included in version v4.0.0-beta.4