payloadcms / payloadcms/payload

Error Cannot use 'in' operator to search for 'name' in undefined when reordering blocks with nested tabs

Open
#14,772 7 comments 0 reactions 1 assignee View on GitHub

@JarrodMFlesch is already working on this.

Since Dec 1, 2025.

status: verified
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

Summary:
When using blocks that contain tabs, reordering blocks in a field can cause a runtime error if a non-default tab is active. Specifically, if a block with more tabs is first and a later block has fewer tabs, switching their positions while the first block’s non-first tab is active triggers:
Cannot use 'in' operator to search for 'name' in undefined

Notes:

  • This seems related to how tabHasName or tab state is handled during block reordering.
  • Workaround: Only reorder blocks when the first tab of each block is active.
Link to the code that reproduces this issue

https://github.com/amir-konimbo/block-tabs-bug

Reproduction Steps
  1. Create a blocks field in a collection/page with at least two block types:
  • Block A: 3 tabs
  • Block B: 2 tabs
  1. Add Block A first, then Block B.
  2. Open Block A and select the 3rd tab (so it becomes active).
  3. Reorder blocks by dragging Block B to be before Block A.
  4. Observe the runtime error in the admin panel.

Expected behavior:

  • Blocks should reorder correctly.
  • Active tabs should either reset safely or persist without causing errors.

Actual behavior:

  • The admin panel throws:
    Cannot use 'in' operator to search for 'name' in undefined
  • The block may appear broken or disappear in the UI.
Which area(s) are affected? (Select all that apply)

area: core

Environment Info
Binaries:
  Node: 22.18.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.64.0
  next: 15.4.7
  @payloadcms/db-mongodb: 3.64.0
  @payloadcms/db-postgres: 3.64.0
  @payloadcms/db-sqlite: 3.64.0
  @payloadcms/drizzle: 3.64.0
  @payloadcms/graphql: 3.64.0
  @payloadcms/live-preview: 3.64.0
  @payloadcms/live-preview-react: 3.64.0
  @payloadcms/next/utilities: 3.64.0
  @payloadcms/plugin-form-builder: 3.64.0
  @payloadcms/richtext-lexical: 3.64.0
  @payloadcms/translations: 3.64.0
  @payloadcms/ui/shared: 3.64.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32476
  Available CPU cores: 16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.