From b2c0f1792b495269f3a9d5fb787f3982a56b61d4 Mon Sep 17 00:00:00 2001 From: Jessica Chowdhury Date: Tue, 18 Nov 2025 11:58:39 +0000 Subject: [PATCH 1/2] fix: ensure restoreAsDraft only updates the published doc when draft false --- .../src/collections/operations/restoreVersion.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/payload/src/collections/operations/restoreVersion.ts b/packages/payload/src/collections/operations/restoreVersion.ts index cf0d5d46f79..ccddff15f54 100644 --- a/packages/payload/src/collections/operations/restoreVersion.ts +++ b/packages/payload/src/collections/operations/restoreVersion.ts @@ -262,13 +262,15 @@ export const restoreVersionOperation = async < result.updatedAt = new Date().toISOString() // Ensure status respects restoreAsDraft arg result._status = draftArg ? 'draft' : result._status - result = await req.payload.db.updateOne({ - id: parentDocID, - collection: collectionConfig.slug, - data: result, - req, - select, - }) + if (!draftArg) { + result = await req.payload.db.updateOne({ + id: parentDocID, + collection: collectionConfig.slug, + data: result, + req, + select, + }) + } // ///////////////////////////////////// // Save restored doc as a new version From 76cf8bb86c61db3bdcb2f8de4fb039027a39b2e1 Mon Sep 17 00:00:00 2001 From: Jessica Chowdhury Date: Tue, 18 Nov 2025 14:37:08 +0000 Subject: [PATCH 2/2] chore: fix test --- test/versions/e2e.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/versions/e2e.spec.ts b/test/versions/e2e.spec.ts index 26df5fb63eb..172bb4400d7 100644 --- a/test/versions/e2e.spec.ts +++ b/test/versions/e2e.spec.ts @@ -306,6 +306,7 @@ describe('Versions', () => { await expect(page.locator('#field-title')).toHaveValue('v2') await page.goto(`${savedDocURL}/api`) + await page.locator('#field-draft').check() const values = page.locator('.query-inspector__value') const count = await values.count()