Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0.0-beta.32] Duplicating block issues with blocks field type #6401

Closed
joedawson opened this issue May 17, 2024 · 6 comments
Closed

[3.0.0-beta.32] Duplicating block issues with blocks field type #6401

joedawson opened this issue May 17, 2024 · 6 comments
Assignees
Labels

Comments

@joedawson
Copy link

Link to reproduction

No response

Describe the Bug

I have a couple of very basic blocks, not doing anything fancy. When I am duplicating any block, whilst it's duplicated, an additional duplicate also appears - however it is empty.

Any blocks that follow the duplicates, also have their state cleared. You can see in the video below, when I duplicate a block the extra duplicate appears as well as the original media block I add is also cleared.

However, not shown in the video, when I publish the value of the blocks re-appear.

Kapture_2024-05-14_at_18.17.22.webm

Here's my fields for reference:

{
  name: 'content',
  label: 'Content',
  type: 'blocks',
  blocks: [
    {
      slug: 'text',
      labels: {
        singular: 'Text',
        plural: 'Text',
      },
      fields: [
        {
          name: 'content',
          label: 'Content',
          type: 'textarea',
          required: true,
        },
      ],
    },
    {
      slug: 'media',
      labels: {
        singular: 'Media',
        plural: 'Media',
      },
      fields: [
        {
          name: 'media',
          label: 'Media',
          type: 'upload',
          relationTo: 'media',
          required: true,
        },
        {
          name: 'caption',
          label: 'Caption',
          type: 'text',
          admin: {
            description: 'Override the media caption (optional)',
          },
        },
      ],
    },
    {
      slug: 'post',
      labels: {
        singular: 'Post',
        plural: 'Posts',
      },
      fields: [
        {
          name: 'post',
          label: 'Post',
          type: 'relationship',
          relationTo: 'posts',
        },
      ],
    },
    {
      slug: 'quote',
      labels: {
        singular: 'Quote',
        plural: 'Quotes',
      },
      fields: [
        {
          name: 'quote',
          label: 'Quote',
          type: 'text',
          required: true,
        },
        {
          name: 'attribution',
          label: 'Attribution',
          type: 'text',
        },
      ],
    },
  ],
}

To Reproduce

  • Create a blocks field on a collection
  • Duplicate a block

Payload Version

3.0.0-beta.32

Adapters and Plugins

db-postgres, storage-s3, plugin-seo

@joedawson joedawson added the status: needs-triage Possible bug which hasn't been reproduced yet label May 17, 2024
@denolfe denolfe added the v3 label May 22, 2024
@JarrodMFlesch JarrodMFlesch added the status: cant-reproduce If an issue cannot be reproduced label May 24, 2024
@JarrodMFlesch
Copy link
Contributor

@joedawson I am unable to reproduce this issue, I tried with both postgres and mongodb. Could you create a repo that I can clone down to ensure we are seeing the same thing? I would also try recreating this in the simplest collection you possibly can.

Thanks!

@joedawson
Copy link
Author

joedawson commented May 24, 2024

@JarrodMFlesch thanks for the response. Not able to replicate it either after forking and copying over my collections (hooks included), config etc.

I just upgraded the project I worked on at the time of reporting this issue to the latest beta (3.0.0-beta.36) but the issue is still happening in my project.

It's worth noting, this does only appear to happen locally and not when deployed (I'm deploying to Vercel). I've also tried:

  • Running payload migrate:fresh
  • deleted all node_modules, lock files etc. and reinstalled everything
  • deleted .next directory
  • tested multiple browsers (cleared caches etc)

Anything else I can maybe try that I may have missed?

@JessChowdhury
Copy link
Member

Hi @joedawson - I've tested this with version beta.32 as you reported and can confirm the behavior. However, this does appear to be resolved on the latest beta 3.0.0-beta.36.

Could I take a look at your package.json file?

A few things that would be worth a check:

  • Are all Payload dependencies updated to 3.0.0-beta.36?
  • Did you reinstall the dependencies after updating? pnpm i or yarn install
  • Did you rebuild your project after updating?

If you are still seeing this bug in your project with 3.0.0-beta.36, please provide us with a stripped back version of your project to help us troubleshoot - essentially this is just a duplicate of your project removing anything sensitive or non-essential.

@JessChowdhury JessChowdhury added the status: needs-repro If an issue does not include a reproduction label May 28, 2024
@github-actions github-actions bot removed status: needs-triage Possible bug which hasn't been reproduced yet status: cant-reproduce If an issue cannot be reproduced labels May 28, 2024
@github-actions github-actions bot removed the status: needs-repro If an issue does not include a reproduction label May 28, 2024
@joedawson
Copy link
Author

joedawson commented May 28, 2024

Hey @JessChowdhury, thanks for taking a look at this issue. I have created a stripped back version of my project as requested here, which of course contains package.json etc: https://github.com/joedawson/block-duplicate-repro

To answer your questions:

  • I followed the breaking changes in the 3.0.0-beta.36 release to bump all next, react dependencies etc. along with all payload 3.0.0-beta.36 dependencies.
  • I use pnpm i to install/reinstall all dependencies
  • If I build my application pnpm run build && pnpm run start - I do not experience the issue, however if I just run the dev server I do experience the issue pnpm run dev

In short, I experience the duplicate issue I originally reported only when running my dev server.

Let me know if you need any more details - thanks!

@JessChowdhury
Copy link
Member

@joedawson thank you for the reproduction! I was finally able to recreate this bug by enabling reactStrictMode: true in the next.config.

Fix opened in this PR.

Copy link

github-actions bot commented Sep 7, 2024

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants