Menu ignores query parameter

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
s4p-gmbh
Posts: 1
Joined: 17 May 2022, 17:09

23 Mar 2023, 00:27

I have an application where some menu entries (second level sub menu) only differ in the query parameter of the URL.
For example:

Link 1: http://localhost/my-application/list.xhtml
Link 2: http://localhost/my-application/list.xhtml?type=opened
Link 3: http://localhost/my-application/list.xhtml?type=closed

With the default layout.js all three menu entries are highlighted as active. I added a workaround for this, which was now overwritten when I upgraded to version 5.1.0. So now I added my workaround again. Can you add a proper fix for this so that I do not always need to apply my workaround?
This is the part of my layout.js that fixes it for two levels:

Code: Select all

restoreMenuState: function() {
		var $this = this;

		if (!this.isSlim() && !this.wrapper.hasClass('menu-layout-horizontal')) {

            var linkList = this.menu.find('a[href^="' + this.cfg.pathname + '"]');
            if (linkList.length) {
                let urlParams = window.location.search;
                linkList.each(function(_i, linkItem) {
                    let setActive = true;
                    let link = $(linkItem);
                    let href = link.attr('href');
                    if (href.includes('?')) {
                        let hrefParams = href.substring(href.lastIndexOf('?'));
                        if (urlParams !== hrefParams) {
                            setActive = false;
                        }
                    }
                    
                    if (setActive) {
                        let menuitem = link.closest('li');
                        menuitem.addClass('active-menuitem');

                        let parentmenu = menuitem.parent('ul');
                        if (parentmenu.length) {
                            parentmenu.slideDown();
                            parentmenu.parent('li').addClass('active-menuitem');
                            
                            // auto-active also for second level menu (s4p)
                            let grandParentMenu = parentmenu.parent('li').parent('ul');
                            if (grandParentMenu.length) {
                                grandParentMenu.slideDown();
                                grandParentMenu.parent('li').addClass('active-menuitem');
                            }
                        }

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

		var inlineProfileCookie = $.cookie('avalon_inlineprofile_expanded');
		if (inlineProfileCookie) {
			this.profileMenu.show().prev('.profile').addClass('profile-expanded');
		}
	},

olgubasak
Posts: 98
Joined: 05 Jan 2023, 11:05

23 Mar 2023, 10:35

Hi,

We'll check and get back to you.

Regards

olgubasak
Posts: 98
Joined: 05 Jan 2023, 11:05

30 Mar 2023, 08:49

Hi again,

We are aware of the issue. We will review your solution and it will be fixed in the next version.

Best Regards,

Post Reply

Return to “Avalon - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests