Skip to content

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

Closed

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

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Mar 17, 2026
  2. added
    area: core
    and removed
    validate-reproduction
    on Mar 17, 2026
  3. removed
    status: needs-triage
    on Mar 17, 2026
  4. added
    status: verified
    on Mar 17, 2026
  5. added a commit that references this issue on Mar 19, 2026
    57a0edc
  6. removed
    status: verified
    on Mar 19, 2026
  7. github-actions commented on Mar 20, 2026

    @github-actions
    Contributor

    🚀 This is included in version v3.80.0

  8. github-actions commented on Mar 28, 2026

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  9. locked as resolved and limited conversation to collaborators on Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bugarea: corearea: trash

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions