I am getting the following error when adding a block with this module enabled on Drupal 10

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array()

This is caused by the following line of code, when $variables['options']['attributes']['class'] is not set.

  if (in_array('use-ajax', $variables['options']['attributes']['class'])) {
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Comments

    stefan.butura created an issue. See original summary.

    stefan.butura’s picture

    StatusFileSize
    new502 bytes
    vbouchet’s picture

    Status: Active » Needs review
    tim-diels’s picture

    Status: Needs review » Needs work

    Hmm this doesn't seem to be a correct solution for the problem. You bail out on the function and do not allow the following code to be executed.
    There is indeed a need for a check. And when the class array does not exist, add it.

    tim-diels’s picture

    Status: Needs work » Needs review

    Ah now i see, the solution is correct here as the code does not have any more need to be executed.
    I'm not using the modal, so didn't got into this situation.

    Can you elaborate on what versions you are using so one can try to reproduce this?

    raveen_thakur51’s picture

    @tim, After saving the block, i am getting this warning only. https://prnt.sc/v0CUXYyKihjx
    Not sure if it is relevant to error @stefan got. I am using Drupal 10.2 and my PHP version is 8.1

    strykaizer’s picture

    Status: Needs review » Fixed

    Status: Fixed » Closed (fixed)

    Automatically closed - issue fixed for 2 weeks with no activity.