When creating multiple Superfish blocks from the same menu, the configuration passed to drupalSettings gets overridden by the last processed block.

Steps to reproduce it:

  1. Create 2 Superfish blocks and place them into the layout
  2. Inspect drupalSettings.superfish

Expected result:
drupalSettings.superfish contains 2 objects. ! for each block

Actual result:
drupalSettings.superfish contains only one object

Now, the issue seems to be the way the HTML ID is generated.
If we take a look at the build implementation of the block we can see the following:

    // Unique HTML ID.
    $html_id = Html::getUniqueId('superfish-' . $menu_name);

    // Preparing the Drupal behavior.
    $build['#attached']['drupalSettings']['superfish'][$html_id]['id'] = $html_id;
    $build['#attached']['drupalSettings']['superfish'][$html_id]['sf'] = isset($sfoptions) ? $sfoptions : array();
    if (!empty($sfplugins)) {
      $build['#attached']['drupalSettings']['superfish'][$html_id]['plugins'] = $sfplugins;
    }

From my investigation $html_id appears to be always the same due to \Drupal\Core\Form\FormBuilder resetting \Drupal\Component\Utility\Html::$seenIds but I'm not sure how to overcome this.

Any suggestion?

Many thanks.
F.

Comments

imfaber created an issue. See original summary.

mehrpadin’s picture

Hey there,

I can't reproduce this, using the latest dev & 8.3.1, perhaps it's some other module(s) interfering?

imfaber’s picture

Status: Active » Closed (works as designed)

Hi

I think you are right, I've tried with a fresh install and I cannot reproduce it neither.
It seems it's due to a view exposed form, in fact if I disable it the menu works as expected.

Thanks for your help.