Serenity Version 5.2.2 - app.menu root Item fire every click

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
zornic
Posts: 71
Joined: 09 Dec 2017, 10:12

20 Apr 2018, 20:53

Hello,

I'm having an issue by clicking on the root item in app.menu:

Code: Select all

secondFloor = [];

secondFloor.push({ label: 'Kategorien', icon: 'receipt', routerLink: ['/SelectionList', eSelectionListType.Ticketsystem_Categories] });
secondFloor.push({ label: 'Teams', icon: 'receipt', routerLink: ['/SelectionList', eSelectionListType.Ticketsystem_Teams] });
firstFloor.push({ label: 'Ticketsystem', icon: 'receipt', items: secondFloor });

this.model.push({
                label: 'Stammdaten', icon: 'menu', items: firstFloor
            });

By clicking on "Stammdaten" fired the clicking Event and moved to "/".

Any help would be appreciated.

Thanks.

merve7
Posts: 861
Joined: 12 Sep 2017, 10:44

25 Apr 2018, 12:44

Maybe, you can try $event.preventDefault() for 'Stammdaten' or other root item.

zornic
Posts: 71
Joined: 09 Dec 2017, 10:12

26 Apr 2018, 16:00

Thank you, i've added in this Method:

@Prime - Fix it in the Serenity Version 5.2.X

Code: Select all

itemClick(event: Event, item: MenuItem, index: number) {
        if (this.root) {
            this.app.menuHoverActive = !this.app.menuHoverActive;
            event.preventDefault();
        }

        // avoid processing disabled items
        if (item.disabled) {
            event.preventDefault();
            return true;
        }

        // activate current item and deactivate active sibling if any
        if (item.routerLink || item.items || item.command || item.url) {
            this.activeIndex = (this.activeIndex as number === index) ? -1 : index;
            event.preventDefault();
        }

        // execute command
        if (item !== undefined && item.command) {
            item.command({originalEvent: event, item: item});
        }

        // prevent hash change
        if (item.items || (!item.url && !item.routerLink)) {
          //setTimeout(() => {
          //  this.appMenu.layoutMenuScrollerViewChild.moveBar();
          //}, 450);
          //  event.preventDefault();
        }

        // hide menu
        if (!item.items) {
            if (this.app.isMobile()) {
                this.app.sidebarActive = false;
                this.app.mobileMenuActive = false;
            }

            if (this.app.isHorizontal()) {
                this.app.resetMenu = true;
            } else {
                this.app.resetMenu = false;
            }

            this.app.menuHoverActive = !this.app.menuHoverActive;
        }
    }

merve7
Posts: 861
Joined: 12 Sep 2017, 10:44

27 Apr 2018, 10:43

Yes. Also we added for next release.

Post Reply

Return to “Serenity - PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests