Skip to content

fix: reuploading file on Save draft resets main doc _status to draft#17011

Open
deepshekhardas wants to merge 1 commit into
payloadcms:mainfrom
deepshekhardas:fix/reupload-file-draft-status
Open

fix: reuploading file on Save draft resets main doc _status to draft#17011
deepshekhardas wants to merge 1 commit into
payloadcms:mainfrom
deepshekhardas:fix/reupload-file-draft-status

Conversation

@deepshekhardas

Copy link
Copy Markdown
Contributor

For an upload-enabled collection with drafts enabled, replacing a published file and saving as a draft incorrectly overwrites the main collection document's _status from 'published' to 'draft'.

The bug was in \collections/operations/utilities/update.ts\ where \data._status = 'draft'\ was set unconditionally when \isSavingDraft\ was true, even when updating an existing published document.

Fix by only setting _status = 'draft'\ for new documents (when id is undefined). For existing documents, the main doc should remain published while a draft version is created.

Closes #16633

For an upload-enabled collection with drafts enabled, replacing a published
file and saving as a draft incorrectly overwrites the main collection
document's _status from 'published' to 'draft'.

The bug was in collections/operations/utilities/update.ts where
data._status = 'draft' was set unconditionally when isSavingDraft was true,
even when updating an existing published document.

Fix by only setting _status = 'draft' for new documents (when id is undefined).
For existing documents, the main doc should remain published while a draft
version is created.

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

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"

1 participant