Skip to content

Slot field named with a key existing within metadata object or somewhere else crashes DnD with arr.some is not a function #1560

@jderboven

Description

@jderboven

Description

Using Puck, defining a slot field with a name that might exist in other object (such as metadata) causes drag‑and‑drop to crash. Renaming the field to breadcrumbSlot fixes the issue immediately.
Environment

  • Package: @puckeditor/core
  • Version: ^0.21.x
  • Framework: React
  • Usage: custom editor with slot fields

Steps to Reproduce

  1. Define a component with a slot field named breadcrumb.
 fields: {
   breadcrumb: { type: 'slot' }
 },
 defaultProps: {
   breadcrumb: []
 }
  1. Insert the component in the editor.
  2. Drag it (or perform a DnD operation).

Expected

  • Drag‑and‑drop should work normally.
    Actual
  • Crash with:
    TypeError: arr.some is not a function
    at containsPromise
    at walkField
    at walkObject

Notes

  • Raw data and defaultProps contain arrays as expected.
  • The non‑array value appears only inside the DnD pipeline, before render.
  • Renaming breadcrumb → breadcrumbSlot fixes the crash.
  • Suggests a collision with an internal field or reserved name.

Proposed Fix

  • Add a defensive guard in mapFields / containsPromise for slot values:
    • If a slot value is not an array, treat it as [] or log a warning.
  • Alternatively, document breadcrumb (and other internal names) as reserved.
  • Better: namespace internal metadata to avoid collisions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions