Skip to content

Fragments can be added to fields that don't have blokkli_fragment in allowedBundles #53

Description

@noahsiegrist

Description

The blokkli editor UI allows dragging/dropping fragments into BlokkliField components even when the underlying Drupal field does not have blokkli_fragment in its target_bundles configuration. The editor should check the field's allowedBundles before showing fragments as droppable options.

Steps to Reproduce

  1. Create a Drupal paragraph field that does NOT include blokkli_fragment in its target_bundles (e.g., a field that only allows text, image, video)
  2. Define a frontend fragment using defineBlokkliFragment():
    defineBlokkliFragment({
      name: 'my_fragment',
      label: 'My Fragment',
    })
  3. Open the blokkli editor on a page with a BlokkliField for that field
  4. Try to add a fragment via the "Add" menu or drag-and-drop

Expected Behavior

  • Fragments should NOT appear in the "Add" menu for fields that don't allow blokkli_fragment
  • Drag-and-drop of fragments should be rejected for fields that don't allow blokkli_fragment
  • Only fields with blokkli_fragment in their allowedBundles (from pbGetFieldConfig or paragraphsBlokkliAllowedTypes) should accept fragments

Actual Behavior

  • Fragments can be added to any field regardless of allowedBundles
  • The operation appears to succeed in the UI
  • Validation errors only surface at publish time (server-side Drupal validation)

Additional Context

The :allowed-fragments prop on BlokkliField filters which specific fragment names are allowed, but it doesn't prevent fragments from being added to fields where blokkli_fragment bundle itself isn't allowed.

GraphQL data available:

  • paragraphsBlokkliAllowedTypes returns allowedTypes per field
  • pbGetFieldConfig returns allowedBundles per field

The editor already receives this data but doesn't use it to filter fragment availability.

Environment

  • @blokkli/editor: 2.0.0-alpha.31
  • drupal/paragraphs_blokkli: 2.0.x-dev
  • Nuxt 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions