Skip to content

Non unique IDs when duplicating block containing Lexical block #11428

Open
@bratvanov

Description

@bratvanov

Describe the Bug

Somewhat related to #8784 / #8790, which was already fixed for nested arrays/nested regular blocks (CC: @r1tsuu)

However, when a Lexical block is nested into a regular block, and the outer regular block is duplicated, the inner Lexical block will still get the same ID as the original Lexical block.

Link to the code that reproduces this issue

bratvanov/payload-lexical-block-duplicate-id@d5f833a

Reproduction Steps

  1. Have a blocks field containing a richText field containing a custom Lexical block.
  2. Duplicate the outer block via the admin UI context (...) menu.
  3. The new block's nested Lexical block has the same ID as the original.
{
    "blockType": "sections",
    "content": {
        "root": {
            "children": [
            {
                "type": "block",
                "fields": {
                    "id": "67c0658ae002eb8c202022bf",
                    "blockType": "simpleBlock"
                }
            }
            ],
        }
    },
    "id": "67c0658618c45a82f4b65509"
},
{
    "blockType": "sections",
    "content": {
        "root": {
            "children": [
            {
                "type": "block",
                "fields": {
                    "id": "67c0658ae002eb8c202022bf",
                    "blockType": "simpleBlock"
                }
            }
            ],
        }
    },
    "id": "67c0658c18c45a82f4b6550e"
}

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

plugin: richtext-lexical, area: core

Environment Info

Node: 22.12.0
payload: 3.24.0
next: 15.1.5
@payloadcms/db-mongodb: 3.24.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions