Skip to content

Localized field data is lost when bulk-trashing draft documents (trash: true + versions.drafts + localized) #15980

@BotEvgen

Description

@BotEvgen

Describe the Bug

When a collection has trash: true, versions.drafts enabled, and localized fields, bulk-trashing documents from the list view causes all localized field data to be cleared. The trashed documents appear with empty localized fields (e.g., title, description) in the trash view and cannot be properly restored.

The root cause is a desynchronization between the main collection table and the versions table. Draft saves (isSavingDraft === true) skip updateOne, so the main table's locale rows are never updated after the initial creation. When a bulk trash operation runs, it reads documents from the main table (via payload.db.find()), which has stale or empty locale data, and creates a new version from that stale data.

Single-document trash (via updateByID) is not affected because it uses getLatestCollectionVersion(), which reads from the versions table.

Recording
https://github.com/user-attachments/assets/901a2e09-a6a6-4012-9540-cd5e54e3ac67

Link to the code that reproduces this issue

https://github.com/BotEvgen/payload

Reproduction Steps

  1. Create a collection with trash: true, versions.drafts (with or without autosave), and at least one localized field.
  2. Create one or more documents and save them as drafts (do not publish).
  3. Go to the collection list view.
  4. Select the documents and click "Move to Trash" (bulk delete).
  5. Navigate to the Trash view.

Observed: All localized fields (e.g., term) are empty / cleared.
Expected: Localized fields retain their values from the latest draft version.

Which area(s) are affected?

area: core

Environment Info

Binaries:
  Node: 22.17.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.79.1
  next: 16.1.6
  @payloadcms/db-postgres: 3.79.1
  @payloadcms/drizzle: 3.79.1
  @payloadcms/graphql: 3.79.1
  @payloadcms/next/utilities: 3.79.1
  @payloadcms/plugin-redirects: 3.79.1
  @payloadcms/richtext-lexical: 3.79.1
  @payloadcms/translations: 3.79.1
  @payloadcms/ui/shared: 3.79.1
  react: 19.2.4
  react-dom: 19.2.4
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 31862
  Available CPU cores: 8

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions