Make WordPress Core

Opened 6 years ago

Last modified 3 years ago

#47436 new defect (bug)

Menu depth doesn't affect menu-item-has-children

Reported by: mikeybinns's profile mikeybinns Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version: 5.2.1
Component: Menus Keywords: needs-patch
Focuses: Cc:

Description

Hi,

When you add a depth of 1 to wp_nav_menu it removes all the sub menus, but it leaves menu-item-has-children class on the original menu li tags, which means it is styled like it has a dropdown.

Attachments (2)

47436.patch (725 bytes) - added by rishishah 6 years ago.
Fix with tests
47436.2.patch (684 bytes) - added by viralsampat 6 years ago.
Updated Patch.

Download all attachments as: .zip

Change History (5)

@rishishah
6 years ago

Fix with tests

#1 @rishishah
6 years ago

  • Keywords has-patch added; needs-patch removed

@viralsampat
6 years ago

Updated Patch.

#2 @mikeybinns
6 years ago

  • Keywords needs-patch added; has-patch removed

These patches work for the first depth (the main line) but the class is also added to lower level submenus.

Example:

Depth = 1
<li class="no-class">
  <a>menu item</a>
</li>

Depth = 2
<li class="menu-item-has-children">
  <a>menu item</a>
  <ul class="sub-menu">
    <li class="menu-item-has-children">
      <a>2nd depth menu item with removed submenu</a>
    </li>
  </ul>
</li>

I think this needs some kind of depth iterator, so the function knows the max depth and the current item depth.

Thanks,
Mikey

#3 @sabernhardt
3 years ago

Related/duplicate: #28620

Note: See TracTickets for help on using tickets.