Skip to content

Block relationship and upload fields in lexical rich text have validation error after auto save #13643

@ApsiV11

Description

@ApsiV11

Describe the Bug

Related to: #13192

When editing a document of a collection with any other field and a lexical rich text field with blocks that have upload and/or relationship fields, saving the document fails to validation errors if any other field other than the lexical field has been edited and auto save is enabled. When creating a new document, this happens only after reloading the page after creating the document.

Additionally, the status of the document is Changed immediately after creating the document and the Publish changes button remains enabled even after clicking it multiple times. This resolves after reloading the page.

The validation errors in question are: block node failed to validate: The following fields are invalid: relationship for the RelationshipBlock and block node failed to validate: The following fields are invalid: upload for the UploadBlock in the reproduction.

Just a guess but this might be caused by changes introduced in: #13438

Link to the code that reproduces this issue

https://github.com/ApsiV11/payload-lexical-bug

Reproduction Steps

  1. Clone the repository
  2. Install dependencies with pnpm install and start the project with pnpm dev and go to the admin panel
  3. Create a new Collection document, add an Upload Block with a reference to Media to the Rich Text Field and save the document.
  4. Reload the page, check the Other field, wait for auto save and try publish the changes. Saving fails to validation errors.
  5. Repeat steps 3 and 4 now using the Relationship Block. Also fails.
  • Additionally also try removing the auto saving from the Collection-collection in the code src/collections/Collection.ts
  • After pushing the schema to the database and repeating steps 3 and 4, the validation errors don't happen anymore

Which area(s) are affected? (Select all that apply)

plugin: richtext-lexical, area: ui

Environment Info

Binaries:
  Node: 24.2.0
  npm: N/A
  Yarn: N/A
  pnpm: 10.10.0
Relevant Packages:
  payload: 3.54.0
  next: 15.4.4
  @payloadcms/db-postgres: 3.54.0
  @payloadcms/email-nodemailer: 3.54.0
  @payloadcms/graphql: 3.54.0
  @payloadcms/next/utilities: 3.54.0
  @payloadcms/payload-cloud: 3.54.0
  @payloadcms/richtext-lexical: 3.54.0
  @payloadcms/translations: 3.54.0
  @payloadcms/ui/shared: 3.54.0
  react: 19.1.0
  react-dom: 19.1.1
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 16076
  Available CPU cores: 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions