WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 7 months ago

#47436 new defect (bug)

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

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

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 7 months ago.
Fix with tests
47436.2.patch (684 bytes) - added by viralsampat 7 months ago.
Updated Patch.

Download all attachments as: .zip

Change History (4)

@rishishah
7 months ago

Fix with tests

#1 @rishishah
7 months ago

  • Keywords has-patch added; needs-patch removed

@viralsampat
7 months ago

Updated Patch.

#2 @mikeybinns
7 months 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

Note: See TracTickets for help on using tickets.