How to replicate:

  1. Create a new menu with a few sample links (not the pre-installed "main" etc)
  2. Place the menu block for the menu in your layout and give it a unique machine name.
  3. Place a second instance of the same menu block in your layout and give it a unique machine name different from the first.
  4. Turn on and view theming suggestions for each with render cache on and off.

Issues & Notes:

  1. The theme suggestions for each block should be different due to different assigned machine names but instead it duplicates the first onto the additional instances leaving no way to use a different TWIG template for each menu block.
  2. When render cache is off we get different suggestions for each block but instead of using the assigned machine name it appends the first instance machine name with --2 etc for the additional instances.
  3. Again note this isn't an issue with the already provided main menu. Just multiple instances of menu blocks for a new menu.

Comments

Soundvessel created an issue. See original summary.

Soundvessel’s picture

Issues

4. There is also a case where main menu block will not respect it's machine name if the block is disabled but supplied to a page template e.g. $variables['content_row_menu_blocks'] = entity_load('block', 'mainnavigation_content_rows')->getPlugin()->build();

Version: 8.1.3 » 8.1.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.1.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

I tested this on Drupal 9.5.x, standard install and was able to reproduce the problem. I don't usually do anything with twig but I didn't have issues testing this. I made a menu block and placed the first instance in the footer and the second in the header. Here are the results without and with caching.

Caching off
First time place block 'newtest'

<!-- FILE NAME SUGGESTIONS:
   * block--footer-bottom--id--newtest.html.twig
   * block--footer-bottom--plugin-id--system-menu-block:newtest.html.twig
   * block--footer-bottom.html.twig
   * block--newtest.html.twig
   * block--system-menu-block--newtest.html.twig
   x block--system-menu-block.html.twig
   * block--system.html.twig
   * block.html.twig
-->

Place another instance of 'newtest' in a different region. There are some suggestions that still show 'newtest' and not 'newtest-2'.

<!-- FILE NAME SUGGESTIONS:
   * block--header--id--newtest-2.html.twig
   * block--header--plugin-id--system-menu-block:newtest.html.twig
   * block--header.html.twig
   * block--newtest-2.html.twig
   * block--system-menu-block--newtest.html.twig
   x block--system-menu-block.html.twig
   * block--system.html.twig
   * block.html.twig
-->

Cache enabled and the results are the same.

<!-- FILE NAME SUGGESTIONS:
   * block--footer-bottom--id--newtest.html.twig
   * block--footer-bottom--plugin-id--system-menu-block:newtest.html.twig
   * block--footer-bottom.html.twig
   * block--newtest.html.twig
   * block--system-menu-block--newtest.html.twig
   x block--system-menu-block.html.twig
   * block--system.html.twig
   * block.html.twig
-->

Place another instance of 'newtest' in a different region. There are some suggestions that still show 'newtest' and not 'newtest-2'.

<!-- FILE NAME SUGGESTIONS:
   * block--header--id--newtest-2.html.twig
   * block--header--plugin-id--system-menu-block:newtest.html.twig
   * block--header.html.twig
   * block--newtest-2.html.twig
   * block--system-menu-block--newtest.html.twig
   x block--system-menu-block.html.twig
   * block--system.html.twig
   * block.html.twig
-->

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.