Skip to content

fix: preserve published main document when saving draft#16643

Open
Rajib-Gupta wants to merge 1 commit into
payloadcms:mainfrom
Rajib-Gupta:fix/payload-preserve-published-doc-when-saving-draft
Open

fix: preserve published main document when saving draft#16643
Rajib-Gupta wants to merge 1 commit into
payloadcms:mainfrom
Rajib-Gupta:fix/payload-preserve-published-doc-when-saving-draft

Conversation

@Rajib-Gupta
Copy link
Copy Markdown

@Rajib-Gupta Rajib-Gupta commented May 16, 2026

fixes #16633

fix: draft save no longer mutates published document when _status: 'published' is present

What?
Fixes draft save behavior so draft: true always creates or updates a draft version without mutating the existing published document, even when the incoming data includes _status: 'published'.

Why?
Previously, the draft-save path checked data._status !== 'published' to determine whether to treat an update as a draft. This meant that when the UI re-sent _status: 'published' alongside a draft save request, the published main record could be incorrectly mutated — or even flipped into draft state.

How?
Draft detection now relies solely on draft: true + hasDraftsEnabled(...), with no dependency on data._status.

Updated draft detection in collection update (packages/.../update.ts)
Updated draft detection in global update (packages/.../update.ts)
Added regression test coverage (int.spec.ts)

Fixes #

@Rajib-Gupta Rajib-Gupta changed the title fix(payload): preserve published main document when saving draft fix: preserve published main document when saving draft May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reuploading a file on "Save draft" resets the main collection document's _status to "draft"

2 participants