Diamond 2.0 SubMenu Can't Stays Expanded

Forum rules
Please note that response time for technical support is within 3-5 business days.
alihasanash
Posts: 15
Joined: 30 Mar 2021, 16:17

06 Dec 2021, 09:26

When I open a subMenu in the menu, it is always automatically collapsed when the subMenu is clicked and redirect to another page.
How to handle this?

Note: In diamond v1.20 the submenu automatically stays open when I click it. This problem appeared after I updated to diamond v2.0.

This is my code:

Code: Select all

<d:menu widgetVar="diamondMenuWidget">
   <p:submenu id="db" label="Database" icon="pi pi-book" >
      <p:submenu id="member" label="Members" icon="pi pi-users" >
         <p:menuitem id="all_member" value="All Member" icon="pi pi-user" outcome="/member/memberList"/>
         <p:menuitem id="sel_member" value="Selected Member" icon="pi pi-user" outcome="/member/selMember"/>
      </p:submenu>
   </p:submenu>   
</d:menu>

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

15 Dec 2021, 10:59

Thanks a lot for the sample code block! I'll check and get back to you.

alihasanash
Posts: 15
Joined: 30 Mar 2021, 16:17

20 Dec 2021, 08:18

mert.sincan wrote:
15 Dec 2021, 10:59
Thanks a lot for the sample code block! I'll check and get back to you.
Thanks, I'll wait for it!

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

24 Dec 2021, 14:03

Fixed for the next version.

Best Regards,

alihasanash
Posts: 15
Joined: 30 Mar 2021, 16:17

27 Dec 2021, 13:10

mert.sincan wrote:
24 Dec 2021, 14:03
Fixed for the next version.

Best Regards,
I've tried Diamond 3.0, this issue is still not resolved

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

28 Dec 2021, 08:12

Please try 3.1.0 version.

Best Regards,

alihasanash
Posts: 15
Joined: 30 Mar 2021, 16:17

28 Dec 2021, 08:39

mert.sincan wrote:
28 Dec 2021, 08:12
Please try 3.1.0 version.

Best Regards,
Still the same..

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

28 Dec 2021, 08:46

Interesting! It works fine for me. Could you please debug 'restoreMenuState' method in your browser's inspector?

Code: Select all

// Line 367
restoreMenuState: function () {
        var isSlimMenu = this.wrapper.hasClass('layout-slim');
        var $this = this;

        if (!isSlimMenu && this.isDesktop()) {
            var link = $this.menu.find('a[href^="' + this.cfg.pathname + '"]');
            if (link.length) {               
                link.addClass('active-route');

    /*** Please check these lines */
                var menuitem = link.parents('li:not(.layout-root-menuitem)');
                menuitem.addClass('active-menuitem').children('ul').show();
   /*******************************/

                setTimeout(function() {
                    $this.restoreScrollState(menuitem);
                }, 100)
            }

            var staticMenuCookie = $.cookie('diamond_static_menu_inactive');
            if (staticMenuCookie) {
                this.wrapper.addClass('layout-static-inactive layout-static-inactive-restore');
            }
        }
    },
Best Regards,

alihasanash
Posts: 15
Joined: 30 Mar 2021, 16:17

28 Dec 2021, 09:23

mert.sincan wrote:
28 Dec 2021, 08:46
Interesting! It works fine for me. Could you please debug 'restoreMenuState' method in your browser's inspector?

Code: Select all

// Line 367
restoreMenuState: function () {
        var isSlimMenu = this.wrapper.hasClass('layout-slim');
        var $this = this;

        if (!isSlimMenu && this.isDesktop()) {
            var link = $this.menu.find('a[href^="' + this.cfg.pathname + '"]');
            if (link.length) {               
                link.addClass('active-route');

    /*** Please check these lines */
                var menuitem = link.parents('li:not(.layout-root-menuitem)');
                menuitem.addClass('active-menuitem').children('ul').show();
   /*******************************/

                setTimeout(function() {
                    $this.restoreScrollState(menuitem);
                }, 100)
            }

            var staticMenuCookie = $.cookie('diamond_static_menu_inactive');
            if (staticMenuCookie) {
                this.wrapper.addClass('layout-static-inactive layout-static-inactive-restore');
            }
        }
    },
Best Regards,
Problem solved!
Sorry, apparently there was still a cache in the browser so I couldn't see any changes after updating to the latest version of Diamond.

Thank you for your help!

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

03 Jan 2022, 10:52

Glad to hear, thanks a lot for the update!

Best Regards,

Post Reply

Return to “Diamond - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests