System Menu blocks do not have attributes

Created on 9 August 2019, over 5 years ago
Updated 25 March 2024, 8 months ago

When viewing system menu blocks placed with layout builder, the blocks do not have title_attributes, contextual links, attributes.id and other commonly required fields for the theme layer.

This causes blocks to be placed with broken id attributes like the following:

<nav role="navigation" aria-labelledby="-menu" data-layout-content-preview-placeholder-label="&quot;Main navigation&quot; block" class="block block-menu navigation menu--main">
      
  <h2 id="-menu">Main navigation</h2>
  

      <div class="content">
        <div class="menu-toggle-target menu-toggle-target-show" id="show-"></div>
    <div class="menu-toggle-target" id="hide-"></div>
    <a class="menu-toggle" href="#show-">Show β€” Main navigation</a>
    <a class="menu-toggle menu-toggle--hide" href="#hide-">Hide β€” Main navigation</a>
    

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'menu__main' -->
<!-- FILE NAME SUGGESTIONS:
   * menu--main.html.twig
   x menu.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/navigation/menu.html.twig' -->

              <ul class="clearfix menu">
                    <li class="menu-item">
        <a href="/" data-drupal-link-system-path="<front>">Home</a>
              </li>
        </ul>
  


<!-- END OUTPUT from 'core/themes/classy/templates/navigation/menu.html.twig' -->


  </div>
</nav>
πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Layout builderΒ  β†’

Last updated 2 days ago

Created by

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    For the specific test coverage still needed.

    Also I see that the tests were updated is that because this attribute is now required? Won't this break existing sites that don't have it?

  • First commit to issue fork.
  • Merge request !6965Add a default ID to system menu blocks β†’ (Open) created by danielveza
  • Status changed to Needs review 9 months ago
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Opened an MR with a slightly different approach.

    The existing patch will add an ID to every since block that is added via LB, which feels a bit overkill to solve this. Instead I've added a default ID that will be applied to system_menu_blocks if one does not exist. If people like this approach I'll add some tests

  • Pipeline finished with Success
    9 months ago
    Total: 613s
    #114338
  • Status changed to Needs work 9 months ago
  • The Needs Review Queue Bot β†’ tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request β†’ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU
  • Status changed to Needs review 8 months ago
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU
  • Status changed to Needs work 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Seems a few other block--system-menu-block.html.twig in core. Is there a place we can add an assertion to?

Production build 0.71.5 2024