Skip to content

Editing a copied inline block also modifies the original #14130

@GermanJablo

Description

@GermanJablo

Describe the Bug

Editing a copied inline block also modifies the original

// _community/collections/Post/index.ts
import type { CollectionConfig } from 'payload'
import { BlocksFeature, lexicalEditor } from '@payloadcms/richtext-lexical'

export const postsSlug = 'posts'

export const PostsCollection: CollectionConfig = {
  slug: postsSlug,
  admin: {
    useAsTitle: 'title',
    enableListViewSelectAPI: true,
  },
  fields: [
    {
      name: 'title',
      type: 'text',
    },
    {
      name: 'content',
      type: 'richText',
      editor: lexicalEditor({
        features: ({ defaultFeatures }) => [
          ...defaultFeatures,
          BlocksFeature({
            inlineBlocks: [
              {
                slug: 'inline-media',
                fields: [
                  {
                    name: 'title',
                    type: 'text',
                  },
                ],
              },
            ],
          }),
        ],
      }),
    },
  ],
}

Link to the code that reproduces this issue

https://github.com/payloadcms/payload

Reproduction Steps

  1. Copy the above snippet to _community/collections/Post/index.ts
  2. pnpm dev
  3. Go to a post and create an inline block
  4. Copy and paste the block to duplicate it.
  5. Modify either of the two and observe the value of the other; it also changes.

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

plugin: richtext-lexical

Environment Info

payload: 3.59.1

Metadata

Metadata

Assignees

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