Magento 2 Admin Panel – Fix 3 Level Menu Structure Not Working

adminmenumagento2.3.0

I am trying to add a menu for my module in the admin panel. I want to add it like Grand Parent > Parent > Child structure.
I have used below code in my menu.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Vendor_Module::jsutariya" title="Grand Parent" module="Vendor_Module" sortOrder="100" resource="Vendor_Module::jsutariya" />
        <add id="Vendor_Module::listgallery" title="Parent" module="Vendor_Module" sortOrder="10" resource="Vendor_Module::listgallery" parent="Vendor_Module::jsutariya" />
        <add id="Vendor_Module::settings" title="Child" module="Vendor_Module"
             sortOrder="40" action="adminhtml/system_config/edit/section/list_gallery"
             resource="Vendor_Module::settings" parent="Vendor_Module::listgallery"/>
    </menu>
</config>

But I can only see Grand parent and child menus. Please check below screenshot.
enter image description here

Best Answer

Honestly, I didn't give the proper answer to your question. But found a way to show the parent menu. Actually, Magento is hiding First "parent" menu via CSS. So you need to add another parent menu and will display your previous parent menu. Here is my code:

    <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
        <menu>
            <add id="Vendor_Module::jsutariya" title="Grand Parent" module="Vendor_Module" sortOrder="100" resource="Vendor_Module::jsutariya" />
            <add id="Vendor_Module::jsutariya_listgallery" title="Parent" module="Vendor_Module" sortOrder="10" resource="Vendor_Module::listgallery" parent="Vendor_Module::jsutariya" />
            <add id="Vendor_Module::jsutariya_settings" title="Child" module="Vendor_Module"
                 sortOrder="40" action="adminhtml/system_config/edit/section/list_gallery"
                 resource="Vendor_Module::settings" parent="Vendor_Module::jsutariya_listgallery"/>
            <add id="Vendor_Module::jsutariya_listgallery1" title="Another Parent" module="Vendor_Module" sortOrder="20" resource="Vendor_Module::listgallery" parent="Vendor_Module::jsutariya" />
        </menu> 
</config>

The main culprit is the following CSS and I don't know why its added in the first place by Magento

.admin__menu .level-0 > .submenu > ul > .level-1:only-of-type > .submenu-group-title {
    display: none;
}
Related Topic