Drupal Content Blocks with Image fields don't work

Created on 23 May 2024, 6 months ago
Updated 7 June 2024, 6 months ago

Problem/Motivation

Drupal Content Blocks with image fields don't work when they are created inline in Gutenberg (i.e. non-reusable). After uploading an image and clicking the "Update Block" button, the form submits but an error pops up in the console

TypeError: settings.data.indexOf is not a function

Steps to reproduce

  1. Create a new Block Type
  2. Add an Image Field
  3. Attempt to create the block in the Gutenberg editor. The block will save but won't update in the editor and the "This Block hasn't been configured..." text will still remain.

Proposed resolution

I think the ajax form submission converts the array of settings.data into a FormData object when there's an image/file field attached. But the check in content-block-utils.js uses Array.prototype.indexOf(), hence the error. It seems like we can probably just check the settings.url instead since the form and route kind of go hand-in-hand. Alternatively we could check the type of settings.data and handle appropriately, but checking the URL seems a little cleaner and simpler. I'll post an MR for that and can discuss further if needed.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇨🇦Canada drclaw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @drclaw
  • Pipeline finished with Success
    6 months ago
    Total: 219s
    #180670
  • Status changed to Needs review 6 months ago
  • Status changed to Fixed 6 months ago
  • 🇵🇹Portugal marcofernandes

    I'm not sure how we could handle this in a more "robust" way but, yes, it seems simpler to just check for the url.
    Good find and thank you for the MR 👏🏼

  • Pipeline finished with Success
    6 months ago
    Total: 292s
    #180934
  • Pipeline finished with Success
    6 months ago
    Total: 322s
    #181910
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Success
    5 months ago
    Total: 212s
    #204752
  • Pipeline finished with Failed
    5 months ago
    Total: 187s
    #213370
  • Pipeline finished with Failed
    4 months ago
    Total: 257s
    #244628
  • Pipeline finished with Success
    4 months ago
    #244654
  • Pipeline finished with Failed
    3 months ago
    Total: 404s
    #253659
  • Pipeline finished with Success
    3 months ago
    Total: 358s
    #253776
  • Pipeline finished with Success
    3 months ago
    #253782
  • Pipeline finished with Failed
    3 months ago
    Total: 570s
    #253795
  • Pipeline finished with Failed
    3 months ago
    Total: 438s
    #254085
  • Pipeline finished with Canceled
    3 months ago
    Total: 117s
    #254117
  • Pipeline finished with Failed
    3 months ago
    Total: 312s
    #254118
  • Pipeline finished with Failed
    3 months ago
    Total: 448s
    #254123
  • Pipeline finished with Failed
    3 months ago
    Total: 514s
    #254683
  • Pipeline finished with Canceled
    3 months ago
    Total: 66s
    #254700
  • Pipeline finished with Success
    3 months ago
    #254701
  • Pipeline finished with Success
    3 months ago
    Total: 431s
    #254926
  • Pipeline finished with Skipped
    3 months ago
    #260837
  • Pipeline finished with Failed
    about 2 months ago
    Total: 362s
    #301448
  • Pipeline finished with Failed
    about 2 months ago
    Total: 189s
    #301470
  • Pipeline finished with Failed
    about 2 months ago
    Total: 172s
    #301473
  • Pipeline finished with Failed
    about 2 months ago
    Total: 163s
    #301478
  • Pipeline finished with Success
    about 2 months ago
    Total: 176s
    #301479
  • Pipeline finished with Skipped
    2 days ago
    #344809
  • Pipeline finished with Success
    1 day ago
    Total: 199s
    #345059
  • Pipeline finished with Success
    1 day ago
    Total: 148s
    #345093
Production build 0.71.5 2024