payload icon indicating copy to clipboard operation
payload copied to clipboard

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

Open talkonimbo opened this issue 3 months ago • 0 comments

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

talkonimbo avatar Dec 01 '25 12:12 talkonimbo